Intro to Ordinary Differential Equations Using Maple
Copy and paste the following (red) maple commands into maple, execute them, and then do the exercise.
Many routines for working with ODEs (and PDEs) are contained in the Maple package, DEtools. This should be first loaded into memory using the with command.
| > | with(DEtools); |
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Entering ODEs in Maplle is the first thing to learn:
| > | diff(y(t),t)+y(t)=exp(-t); |
| > | diff(y(t),t)-y(t)=sin(t); |
| > | m*diff(x(t),t$2)+b*diff(x(t),t)+k*x(t)=0; |
| > | diff(y(t),t$4)-10*diff(y(t),t$3)+35*diff(y(t),t$2)-50*y(t)+24=5*exp(t); |
| > | des := diff(y(t),t) = z(t) - y(t),diff(z(t),t) = y(t); |
Exercise: Enter the ODE, y'' + y = 2cos(x) + 1.
Maple can sometimes tell if a ODE is separable (resp., linear, homogeneous) or not (NONE means either "no" or "unknown"):
| > |
| > | de:=diff(y(t),t)=y(t);
odeadvisor(de,[homogeneous]); odeadvisor(de,[separable]); odeadvisor(de,[linear]); |
| > | de:=diff(y(t),t)+y(t)=exp(-t);
odeadvisor(de,[homogeneous]); odeadvisor(de,[linear]); odeadvisor(de,[separable]); |
| > | de:=diff(y(t),t)+y(t)=1;
odeadvisor(de,[homogeneous]); odeadvisor(de,[linear]); odeadvisor(de,[separable]); |
| > | de:=diff(y(t),t)+y(t)^2=0;
odeadvisor(de,[homogeneous]); odeadvisor(de,[linear]); odeadvisor(de,[separable]); |
| > | de:=diff(y(t),t)+y(t)^2=1;
odeadvisor(de,[homogeneous]); odeadvisor(de,[linear]); odeadvisor(de,[separable]); |
| > | de:=diff(y(t),t$2)+y(t)=1;
odeadvisor(de,[homogeneous]); odeadvisor(de,[linear]); odeadvisor(de,[separable]); |
| > | de:=diff(y(t),t$2)^2+y(t)=1;
odeadvisor(de,[homogeneous]); odeadvisor(de,[linear]); odeadvisor(de,[separable]); |
Exercise: COnsider the ODE, y' + cos(y) = x - 1. Type this into Maple and see if it thinks it is homogeneous, linear, or separable.
Solving ODEs can be done using the dsolve command.
| > | de:=diff(y(t),t)+y(t)=exp(-t);
dsolve(de,y(t)); |
| > | de:=diff(y(t),t)+y(t)=exp(-t);
ic:=y(0)=3; dsolve({de,ic},y(t)); |
| > |
| > | de:=(m,b,k)->m*diff(x(t),t$2)+b*diff(x(t),t)+k*x(t)=0:
de(m,b,k); de(1,0,1); dsolve(de(1,0,1),x(t)); |
| > | ics:=x(0)=1,D(x)(0)=1;
dsolve({de(1,0,1),ics},x(t)); |
| > |
| > | des := diff(y(t),t) = -z(t) ,diff(z(t),t) = y(t);
ics:=y(0)=0, z(0)=1; dsolve({des,ics}, {y(t), z(t)}); |
| > | des := diff(y(t),t) = 4*z(t) ,diff(z(t),t) = y(t);
ics:=y(0)=0, z(0)=1; dsolve({des,ics}, {y(t), z(t)}); |
Exercise: Solve y' - y = x, y(0) = 1, using dsolve.
Plotting solutions to ODEs can be done using the DEplot command.
| > | de:=(m,b,k)->m*diff(x(t),t$2)+b*diff(x(t),t)+k*x(t)=0:
DEplot(de(1,0,1), {x(t)}, 0..10, [[x(0)=3, D(x)(0)=-2]],title=`Damped Oscillator`); |
![[Plot]](images_intro_ode/sm212_intro_ode0_55.gif)
| > | de:=(m,b,k)->m*diff(x(t),t$2)+b*diff(x(t),t)+k*x(t)=0:
DEplot(de(1,0.1,1), {x(t)}, 0..10, [[x(0)=3, D(x)(0)=-2]],title=`Damped Oscillator`); |
![[Plot]](images_intro_ode/sm212_intro_ode0_56.gif)
| > | de:=(m,b,k)->m*diff(x(t),t$2)+b*diff(x(t),t)+k*x(t)=0:
DEplot(de(1,0,1), {x(t)}, 0..10, [[x(0)=3, D(x)(0)=-4]],title=`Damped Oscillator`); |
![[Plot]](images_intro_ode/sm212_intro_ode0_57.gif)
Note the subtle difference between the 1st and last graph.
Exercise: Plot the solution to y' + y = 1, y(0) = -1, for 0 < x < 3.
Systems of Equations - Dynamical System Model
| > | des := diff(x(t),t) = -4*y(t),diff(y(t),t) = -x(t);
DEplot({des}, [x(t),y(t)], 0..(0.5), [[x(0)=100,y(0)=100]], title=`plot of (x(t),y(t)), t=0..2`); |
![[Plot]](images_intro_ode/sm212_intro_ode0_59.gif)
| > | des := diff(x(t),t) = 2.9*x(t)-4*y(t),diff(y(t),t) = -x(t);
DEplot({des}, [x(t),y(t)], 0..(0.9), [[x(0)=100,y(0)=100]], title=`plot of (x(t),y(t)), t=0..2`); |
![[Plot]](images_intro_ode/sm212_intro_ode0_61.gif)
| > |
Phase portraits:
| > | de := diff(y(x),x)+y(x)=cos(x);
phaseportrait(de, y(x), x=-1..15, [[y(0)=0],[y(0)=1],[y(0)=-1]], title=`Asymptotic Solution`, color=magenta, linecolor=[red,blue,green]); |
![[Plot]](images_intro_ode/sm212_intro_ode0_63.gif)
Exercise: Plot the phase portrait to y' + y = 1, y(0) = -1, = 0, = 1, for -2 < x < 2.
| > |
For more examples, see
http://www.mapleapps.com/powertools/des/des.shtml
http://www.mapleapps.com/categories/maple_tools/functionality/html/odes1.html
http://www.mapleapps.com/List.asp?CategoryID=7&Category=Differential%20Equations
| > |