16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.1. PHASE-PLANE ANALYSIS 79<br />

> sol2:=[seq(allvalues(sol[i]),i=1..N)];<br />

"<br />

"<br />

p # "<br />

p #<br />

3<br />

3<br />

sol2 := [x =0;y=0]; x =0;y= ; x =0;y= ¡ ;<br />

3<br />

3<br />

" p<br />

5<br />

[x =1;y=0]; [x = ¡1; y=0]; x =<br />

5 ;y=<br />

p #<br />

30<br />

;<br />

15<br />

" p p # " p<br />

5 30<br />

5<br />

x = ;y= ¡ ; x = ¡<br />

5 15<br />

5 ;y=<br />

p # " p p ##<br />

30<br />

5 30<br />

; x = ¡ ;y= ¡<br />

15<br />

5 15<br />

In the sol2 list of lists, there are clearly nine lists of x and y values, corresponding<br />

to the coordinates of nine stationary points. There is indeed a plethora<br />

of ¯xed points in this example. The number of operands (lists here) will be<br />

needed, so this number is extracted with the nops command.<br />

> N2:=nops(sol2);<br />

N2 := 9<br />

Functional operators are formed to numerically evaluate p = ¡(a + d) and<br />

q = ad¡ bc for the ith entry in sol2 .<br />

> p:=i->evalf(eval(-(a+d),sol2[i])):<br />

> q:=i->evalf(eval(a*d-b*c,sol2[i])):<br />

Next, Jennifer creates a do loop, running from i =1toN2 = 9, to identify the<br />

nature of each ¯xed point and to plot each point.<br />

> for i from 1 to N2 do<br />

The ith entry (list of x and y coordinates) of sol2 is entered, and then the x and<br />

y coordinates are extracted separately. For example, taking i =1,sol2[1,1]<br />

extracts the ¯rst entry (x = 0) in the ¯rst list of sol2 , while sol2[1,2] produces<br />

the second entry (y = 0). The right-hand sides are extracted to give the x and<br />

y coordinates of the ¯xed point for plotting purposes.<br />

> sol2[i]; X[i]:=rhs(sol2[i,1]); Y[i]:=rhs(sol2[i,2]);<br />

The values of p, q, andr = p2 ¡ 4 q are determined for the ith ¯xed point. Jennifer<br />

uses the concatenation operator || to attach numbers to these quantities.<br />

For example, the outputs of p||1, p||2, etc., would be of the form p1 , p2 ,etc.<br />

Concatenation is a useful alternative way of numbering quantities.<br />

> p||i:=p(i); q||i:=q(i); r||i:=simplify(p||i^2-4*q||i);<br />

A conditional statement is now entered that will classify the ith ¯xed point<br />

according to the region of the p-q diagram in which it is located. The general<br />

syntax for a conditional statement is<br />

if then <br />

elif then <br />

else <br />

end if<br />

where the elif (else if) and else phrases are optional.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!