lecture1.mws

> restart:with(linalg):with(plots):with(DEtools):macro(olive = COLOR(RGB, 0, 0.7, 0)):

Warning, the protected names norm and trace have been redefined and unprotected

Warning, the name changecoords has been redefined

Warning, the name adjoint has been redefined

Example 1

Coffee cooling down

> de:=diff(y(t),t)=k*(tout-y(t));

de := diff(y(t), t) = k*(tout-y(t))

> tout:=70:k:=0.05:

> fplot:=dfieldplot(de,y(t),t=0..100,y=30..200,arrows=SLIM):

> display(fplot);

[Plot]

> sol:=dsolve({de,y(0)=160},numeric,range=0..100):

> display(odeplot(sol,color=blue,thickness=4),fplot);

[Plot]

>

2

Owls and mice

> de:=diff(p(t),t)=0.5*p(t)-450;

de := diff(p(t), t) = .5*p(t)-450

> fplot:=dfieldplot(de,p(t),t=0..5,p=800..1000,arrows=SLIM):

> display(fplot);

[Plot]

> de:=diff(y(t),t)+1/2*y(t)=2+t;

de := diff(y(t), t)+1/2*y(t) = 2+t

> fplot:=dfieldplot(de,y(t),t=-10..10,y=-25..25,arrows=SLIM):display(fplot);

[Plot]

> sol:=dsolve({de,y(0)=2},numeric,range=-10..10):display(odeplot(sol,color=blue,thickness=4),fplot);

[Plot]

>

3

> de:=diff(y(t),t)+y(t)*tan(t)=2*t*cos(t);

de := diff(y(t), t)+y(t)*tan(t) = 2*t*cos(t)

> fplot:=dfieldplot(de,y(t),t=-5..5,y=-10..10,arrows=SLIM):display(fplot);

[Plot]

> sol1:=dsolve({de,y(0)=5},numeric,range=-5..5):sol2:=dsolve({de,y(-2)=1},numeric,range=-5..5):display(odeplot(sol1,color=blue,thickness=4),odeplot(sol2,color=blue,thickness=4),fplot);

[Plot]

>

4

> de:=diff(y(t),t)+(2/t)*y(t)=4*t;

de := diff(y(t), t)+2*y(t)/t = 4*t

> fplot:=dfieldplot(de,y(t),t=-2..2,y=-2..4,arrows=SLIM):display(fplot);

[Plot]

> sol:=dsolve({de,y(1)=2},numeric,range=-2..2):display(odeplot(sol,color=blue,thickness=4),fplot);

Warning, cannot evaluate the solution further left of .38651527e-102, probably a singularity

[Plot]

> lines:=[]:ivps:=[-1,-1],[-1,1.5],[-1,2],[-1,1.1],[-1,0.5],[-1,0.92],[-1,1],[1,-1],[1,1.5],[1,2],[1,1.1],[1,0.5],[1,0.92],[1,1]:

> for i in ivps do

>  sol:=dsolve({de,y(i[1])=i[2]},numeric,range=-2..2):

>  myline:=odeplot(sol,color=blue,thickness=2):

>  lines:=[op(lines),myline]:

> end do:

Warning, cannot evaluate the solution further right of -.50755375e-102, probably a singularity

Warning, cannot evaluate the solution further right of -.29780864e-102, probably a singularity

Warning, cannot evaluate the solution further right of -.38651527e-102, probably a singularity

Warning, cannot evaluate the solution further right of -.17671334e-102, probably a singularity

Warning, cannot evaluate the solution further right of -.32751464e-102, probably a singularity

Warning, cannot evaluate the solution further right of -.16784322e-102, probably a singularity

Warning, cannot evaluate the solution further right of -.16250952e-104, probably a singularity

Warning, cannot evaluate the solution further left of .50755375e-102, probably a singularity

Warning, cannot evaluate the solution further left of .29780864e-102, probably a singularity

Warning, cannot evaluate the solution further left of .38651527e-102, probably a singularity

Warning, cannot evaluate the solution further left of .17671334e-102, probably a singularity

Warning, cannot evaluate the solution further left of .32751464e-102, probably a singularity

Warning, cannot evaluate the solution further left of .16784322e-102, probably a singularity

Warning, cannot evaluate the solution further left of .16250952e-104, probably a singularity

> display(lines,fplot);

[Plot]

>

5

> de:=diff(y(x),x)=(1+cos(x))/(1+3*y(x)^2);

de := diff(y(x), x) = (1+cos(x))/(1+3*y(x)^2)

> fplot:=dfieldplot(de,y(x),x=-10..10,y=-2..2,arrows=SLIM):display(fplot);

[Plot]

> sol:=dsolve({de,y(-5)=-1},numeric,range=-10..10):display(odeplot(sol,color=blue,thickness=4),fplot);

[Plot]

>

6

> de:=diff(y(x),x)=-3*x^2*y(x)^2;

de := diff(y(x), x) = -3*x^2*y(x)^2

> fplot:=dfieldplot(de,y(x),x=-5..5,y=-1.5..1.5,arrows=SLIM):display(fplot);

[Plot]

> sol:=dsolve({de,y(2)=1},numeric,range=root(7,3)..5):display(odeplot(sol,color=blue,thickness=4),fplot);

[Plot]

> lines:=[]:ivps:=[0,1],[0,-1],[-2,1],[-2,0.1]:

> for i in ivps do

>  sol:=dsolve({de,y(i[1])=i[2]},numeric,range=-5..5): myline:=odeplot(sol,color=blue,thickness=2):

>  lines:=[op(lines),myline]:

> end do:

Warning, cannot evaluate the solution further left of -.99999857, probably a singularity

Warning, cannot evaluate the solution further right of .99999857, probably a singularity

Warning, cannot evaluate the solution further left of -2.0800838, probably a singularity

Warning, cannot evaluate the solution further left of -2.6207409, probably a singularity

> display(lines,fplot);

[Plot]

>

7

> de:=diff(y(x),x)=(3*x^2+4*x+2)/(2*(y(x)-1));

de := diff(y(x), x) = (3*x^2+4*x+2)/(2*y(x)-2)

> fplot:=dfieldplot(de,y(x),x=-2.5..2.5,y=-2..3,arrows=SLIM):display(fplot);

[Plot]

> sol1:=dsolve({de,y(0)=-1},numeric,range=-2..2):display(odeplot(sol1,color=blue,thickness=4),fplot);

[Plot]

> lines:=[]:ivps:=[0,3],[-1,0],[0,0],[0,2],[-1,2],[1,0],[1,2]:

> for i in ivps do

>  sol:=dsolve({de,y(i[1])=i[2]},numeric,range=-5..5):

>  myline:=odeplot(sol,color=olive,thickness=4):

>  lines:=[op(lines),myline]:

> end do:

Warning, cannot evaluate the solution further left of -2.0000071, maxfun limit exceeded (see ?dsolve,maxfun for details)

Warning, cannot evaluate the solution further left of -1.5436897, maxfun limit exceeded (see ?dsolve,maxfun for details)

Warning, cannot evaluate the solution further left of -1.0000020, maxfun limit exceeded (see ?dsolve,maxfun for details)

Warning, cannot evaluate the solution further left of -1.0000021, maxfun limit exceeded (see ?dsolve,maxfun for details)

Warning, cannot evaluate the solution further left of -1.5436898, maxfun limit exceeded (see ?dsolve,maxfun for details)

Warning, cannot evaluate the solution further left of .88123912, maxfun limit exceeded (see ?dsolve,maxfun for details)

Warning, cannot evaluate the solution further left of .88123902, maxfun limit exceeded (see ?dsolve,maxfun for details)

> display(lines,odeplot(sol1,color=blue,thickness=4),fplot);

[Plot]

>

8

> de:=diff(y(x),x)+2*y(x)=y(x)^3;

de := diff(y(x), x)+2*y(x) = y(x)^3

> fplot:=dfieldplot(de,y(x),x=-2.5..2.5,y=-3.5..3.5,arrows=SLIM):display(fplot);

[Plot]

> lines:=[]:ivps:=[0,3],[0,2],[0,1],[0,0.2],[0,-0.5],[0,-1],[0,-1.5],[0,-2],[-2,-1]:

> for i in ivps do

>  sol:=dsolve({de,y(i[1])=i[2]},numeric,range=-2.5..2.5):

>  myline:=odeplot(sol,color=blue,thickness=2):

>  lines:=[op(lines),myline]:

> end do:

Warning, cannot evaluate the solution further right of .62828567e-1, probably a singularity

Warning, cannot evaluate the solution further right of .17328674, probably a singularity

Warning, cannot evaluate the solution further right of .54930721, probably a singularity

Warning, cannot evaluate the solution further right of .17328674, probably a singularity

> display(lines,fplot);

[Plot]