## dharr

Dr. David Harrington

## 6416 Reputation

20 years, 23 days
University of Victoria
Professor or university staff

## Social Networks and Content at Maplesoft.com

I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

## Mapleprimes...

Sometimes the Mapleprimes worksheet display is broken for a time, and the files display incorrectly as you saw. But sometimes there is just something slightly different about a file that leads to problems, as is the case here. I opened your file and had the same poblem uploading, then deleted the last two plots and then redid them. Now it seems identical but can upload.

 This project discusses predator-prey system, particularly the Lotka-Volterra equations,which model the interaction between two sprecies: prey and predators. Let's solve the Lotka-Volterra equations numerically and visualize the results. Now, we need to handle a modified version of the Lotka-Volterra equations. These modified equations incorporate logistic growth fot the prey population.

## solving 2 equations...

In your first section of code, after the first solve, you assign x[2]^2/3 to x[1]. So now fx is (x[2]^2/3)^2 - 3*x[2] = 0, so a quartic equation in x[2]. When you solve it you get the 4 roots of this quartic. So this is correct.

A better approach is to just solve the two equations simultaneously, i.e., let Maple do the work for you.

`sol := solve({fx, fy},{x[1],x[2]})`

you could then use assign to set the values of x[1] and x[2], or better, use the solution you want with eval to work out other things involving x[1] and x[2].

 >
 >

 >

[] are optional below, but allows you to, e.g, count solutions

 >

Example: value of F4 for the 4th solution

 >

 >

## InertForm...

I assume you are OK with the standard mathematical way of writing the limit. Then the following works.

`InertForm:-Display(`%>`(%limit(X[i] %^ (rho = 0), alpha = infinity), 0), inert = false)`

## one sqrt...

Maple calculates THE sqrt (sqrt is a function); sqrt(4) does not give +/-2. From the help page "sqrt(x) represents the "principal square root", defined by the formula sqrt(x) = exp(1/2 * ln(x))".

## coeffs or solve,identity...

coeffs finds all the coefficients, and then they can be used in solve (by default solve assumes they are equal to zero). But solve(identity(,...) automates this process. There is no solution for eq4, but for eq1 if you do not specify q[0], then there is a trivial solution.

Solve_for_coefficients2.mw

## bug...

I'd say it is a bug. A workaround if to use evalf

```sol:=[-1/4*x^2, (-1/2-1/2*(-3)^(1/2))^2+(-1/2-1/2*(-3)^(1/2))*x, (-1/2+1/2*(-3)^(1/2))^2+(-1/2+1/2*(-3)^(1/2))*x];
plot(evalf(sol),legend=sol)```

## complexplot3d...

I've added missing information with random values. This gives a magnitude plot colored by phase.

ps - if providing code, please don't include the output.

 > restart;
 > local gamma;

Added random values for the parameters theta and gamma

 > params := {alpha = 2.5, k = 3, w = 2, beta[3] = 3, beta[4] = 1.7, theta = 0, gamma = 0.2}; xi := beta[3]*(2*alpha*k*t + x)*sqrt(1/(36*alpha*beta[4] + 36*gamma*beta[4]));

We perhaps want to plot the magnitude and color it with the phase - so make [mag, phase]

 > sol1 := [U(xi), (-sqrt(1/(36*alpha*beta[4] + 36*gamma*beta[4]))*x + w*t + theta)];

Assume some functional form for U(xi)

 > sol2 := eval(sol1, U(xi) = xi^2);

insert numerical values

 > solnum :=eval(sol2, params);

 > plots:-complexplot3d(solnum, x = 0.. 5, t = 0..5);

 >

## guess...

If you try

```for y in [0, 0.5, 1, 5, 10] do
p := plot(y);
plottools:-getdata(p, rangesonly);
end do;```

Then the y range is always reported just y..y, but the actual ranges are

y=0: -1..1

other y:   y-y/2..y+y/2

so perhaps that is a general rule.

The plot,ranges help just says "If the vertical range is unspecified, a suitable range will be deduced from the values computed" :-(

## dsolve...

dsolve works here, and finds a simple correct solution. I'm guessing something about the problem is not correctly formulated here.

 >
 >
 >

Original divided by

 >

 >

 >

 >

 >

Error, (in dsolve/numeric/bvp) system is singular at left endpoint, use midpoint method instead

 >

 >

Indeed K=0 and f=1 is a solution.

 >

 >

## some suggestions...

You have a large polynomial system that is going to be slow. Among other changes, removing the explicit option saves about 25%. I have also added general suggestions that may be useful in the future.

new1.mw

## select...

Your worksheet does not run so I copied the output.

 >
 >

You can select by number

 >

select(has, .., is useful here. Note the [] around sol.

 >

remove or selectremove may also be useful.

 >

## convert, polynom...

The problem is the O(h^7) term. If q is your expand(SUMY-T) then

`coeff(convert(q, polynom), h, 6)`

(actually you should remove it from SUMY)

## difficult...

I don't see any way in the general case. But Z2 is simple enough to do. The comments suggest why it will be difficult in the general case. Zp is the cyclic group of order p.

 >
 >
 >

Construct direct product Zp x Zp. Goes to Z x Z in limit of large p.

 >

 >

Torus as expected

 >

The problem is that the order of the elements is not useful, and the representation is not unique, e.g., b^2 can be b^3.b^-1. So we need some manipulations that are easy here but wont be in the general case.

 >

Find the orders of a and b

 >
 >

We want to split between degrees 5 and 6. Make an Array of the element numbers indexed by the degrees

 >

Delete arcs between 5 and 6. In this case we know the arc directions, but in the more general case this won't be true.

 >

 >

And we get part of an infinite grid, as expected.

 >

 >

## showstat...

Try

`showstat(Units:-TestDimensions);`

## assumptions with invlaplace...

invlaplace very often needs assumptions to make progress. Even though s is complex, assuming everything is positive often seems to work. I just worked out lap3, since I am out of time, but this method is probably enough to get the rest done.

 >
 >
 >
 >

Work with the three parts separately

 >

part 1 by hand. L1 is invlaplace of (laplace divided by s^alpha)

 >

 >

Part 3 requires some assumptions that work even if they aren't correct

 >

 >

 >