Math 315 Computer Tools
There is a collection of Java Applets that allow interactive work with
differential equations at the
Interactive Math Programs website. For example, the applet program
"DIRFLD" plots direction fields; select "Print" from the "File" icon
in your web browser to print a direction field produced by "DIRFLD".
The computer tools Maple and Matlab are available online from the Math
Department
MyMath Math Portal.
Online information about Matlab is given at the
Matlab information website.
Some tutorial information about Maple is given at this
Maple tutorial website, with more details given at this
second Maple tutorial website.
Here are some Maple and Matlab example commands for working with
differential equations.
-
Assume you want to solve y' = exp(-t) - 2y, given y(1) = 1.
- MAPLE
- To plot a direction field that includes a solution plot use:
with(DEtools):
DEplot({ diff(y(t),t) = exp(-t) - 2*y(t) },y(t),t=-2..3,[[y(1)=1]]);
- To solve the equation symbolically use:
dsolve( { diff(y(t),t) = exp(-t) - 2*y(t), y(1) = 1 }, y(t) );
- MATLAB
- To plot a direction field use:
[T,Y] = meshgrid( -2:.2:3, -1:.2:2 );
S = exp(-T) - 2*Y; L = sqrt(1+S.^2);
quiver( T, Y, 1./L, S./L, 0.5 );
axis equal tight
title('y'' = exp(-t) - 2*y(t) Dir. Field')
- To solve the equation symbolically and plot the solution use:
sol = dsolve('Dy = exp(-t) - 2*y, y(1) = 1','t'); pretty(sol)
ezplot( sol, [-2, 3] )
- To solve the equation numerically and plot the solution use:
f = inline('exp(-t) - 2*y', 'y','t'); ode45( f, [0, 3], 1 )
- In MAPLE:
- to produce implicit equation plots
for y^2/2 + exp(t)(1-2) = C, use:
e:=y^2/2 + exp(t)*(t-1): with(plots):
implicitplot({e=1,e=2,e=3},t=-2..2,y=-4..4);
-
to produce the first 9 terms of the series solution for
cos(x)y''+xy'-2y=0, near x = 0, with y(0) = 1, y'(0) = 2, use:
Order := 9;
eqn := cos(x)*diff(diff(y(x),x),x) + x*diff(y(x),x) - 2*y(x) = 0;
dsolve({eqn, y(0) = 1, D(y)(0) = 2}, y(x), type = series );
- to plot a phase portrait
for x'= 3x-2y, y'= 2x-2y, and two solutions with
respective initial values [x(0)=2,y(0)=2] and [x(0)=-2,y(0)=-2], use:
with(DEtools):
phaseportrait([D(x)(t)=3*x(t)-2*y(t),D(y)(t)=2*x(t)-2*y(t)],[x(t),y(t)],t=-1..1,[[x(0)=2,y(0)=2],[x(0)=-2,y(0)=-2]]);