Math 255 Differential Equations
Computer/Calculator Information
Here is what I know so far as to the computer packages and calculator
for doing the routine calculations- if you have any additions please
let me know you can email me
here
Note that in general these CAS programs have very good help menus- for
example in Maple click on the "Help" tab then pull down to "Using
Help". There is a ton of info here- and with each topic there are
examples- if you like you can cut and paste these into a new worksheet
and see them work- modify them etc. So the best thing to do is explore
in the help menus and try some different things.
TI-89 calculator:
Apparently this will do direction fields:
Click Mode, then under graph select diff equations, then when you go to
graph a function {green diamond then F1/y=} it will give you the option
y1'= and you can enter what you want for the Diff. eqn. you can also
set y1= something but we did not figure out what this does. Note that
the indep. variable is assumed to be "t" and the dep. var is y1 {you do
not need y1(t), or y2 or y3 depending on which you enter}
Maple:
To create a slope field: type with(DEtools); {note that the semi-colon
always tells maple it is the end of a command, and this command tells
Maple to load the special diff. eq.s stuff}
Then an example of the command is:
Even better is DEplot you can also add initial conditions
DEplot(diff(y(x),x)=x^2+y(x)^2,y(x), x=-5..5,y=-4..4);
DEplot(diff(y(x),x,x)=x^2+y(x)^2,y(x),
x=-5..5,y=-4..4,[[y(0)=1,D(y)(0)=2]]);
dfieldplot(diff(y(x),x)=1/2*(-x-(x^2+4*y(x))^(1/2)), y(x), x=-3..3,
> y=-3..2, title=`Restricted domain`,color=1/2*(-x-(x^2+4*y)));
Not all this is necessary, you can just ignore the title, and color
stuff- the important part is the eqn should be of the form diff(y(x),x)
{this is just dy/dx} = whatever function of y and x that you want, then
put ",y(x)" which tells it the thing to solve for is y(x)- note
whenever you write y in this case you write y(x) to remind maple that y
is a function of x {this is also why there is a y(x) that follows the
dy/dx= part}. Also remember to set the range of values for x,y. So if
we want to plot dy/dx=x^2+y^2 we would type:
dfieldplot(diff(y(x),x)=x^2+y^2, y(x), x=-3..3, y=-3..2);
Here is what I got:
dsolve is the command for solving differential equations
dsolve(diff(y(x),x)=3*y(x),y(x));
With initial conditions:
dsolve( {diff(y(t),t,t)+diff(y(t),t)^2=0 , y(0)=3},
y(t));
dsolve( {diff(y(t),t,t)+diff(y(t),t)^2=0,
y(0)=3, D(y)(0)=0}, y(t));
Other neat commands:
intfactor looks for an integrating factor to use on an ODE
Ex. Mu := intfactor(diff(y(x),x,x) =
(y(x)*x+y(x)*ln(x)*x^2+diff(y(x),x)*ln(x)*x^2)/ln(x)/x^2*exp(x)-
y(x)/ln(x)/x^2);
constcoeffsols solves any order linear ODE with constant coefficients
Ex. constcoeffsols(3*diff(z(t),t$3) + diff(z(t),t$2)
- diff(z(t),t) - 3*z(t) = 0, z(t) )
exactsol looks for an exact ODE
Ex. exactsol( 3*t^3*z(t)^2 * diff(z(t),t) +
3*t^2*z(t)^3 = 0, z(t) );
linearsol finds solutions to any first order linear ODE
Ex. linearsol( diff(z(t),t) + p(t)*z(t) = q(t), z(t)
);
More to come:
Mathematica:
Note that one trick with mathematica is hitting
enter just moves to the
next line- if you want it to do the calculation you need to hit Shift
and enter at the same time (or just the enter on the number pad).
DSolve will give algebraic solutions to diff. eqs.
{Mathematica expects
square brackets for functions of a variable- it treats parentheses as
just a multiplication, i.e. y[x] means y is a function of x but y(x)
means multiply x and y}.
Note also that in Mathematica, you must use x == y
(2"=" signs together) to mean x is equal to y, one = sign means set x
equal to y. If you make a mistake and run a command with something like
y''[x]=y[x], Mathematica sets the "variable" y''[x] equal to y[x] and
it will not forget this unless you tell it to clear the "variable"- so
if you try it again it will just say "true" since it thinks you are
asking it if y''[x] is = y[x]. To fix this sort of problem there are
four options.
1) Quit Mathematica and start again (will work but need to start over-
save your worksheet though)
2) Select Quit Kernel (Local) from the top menu under Kernel then
select Start Kernel (Local) this will erase the memory of the program
so far- so all of your commands will still be there but it is like
starting fresh.
3) Use the command Unset[y''[x]] or y''[x]=. (i.e. write y''[x]
equal to period - this should clear the value)
Example I input:
DSolve[y''[x] = y[x], y[x], x]
It gave me : DSolve::"deqn": "Equation or list of equations expected
instead of \!\(y[x]\) \
in the first argument y[x]"
If I do it again now:
DSolve[y''[x] = y[x], y[x], x] it gives me another error and it gives:
DSolve[y[x], y[x], x] note that it thinks y''[x] is actually equal to
y[x] as a variable so it replaced it- and is confused. So now I input
y''[x]=. or Unset[y''[x]] and it does not give an output but now I run
it again with 2 = signs
DSolve[y''[x] == y[x], y[x], x] and it gives me : ({{y[x]-> e^xC[1]
+ e^(-x) C[2]}}). This is also true when dealing with initial
conditions- i.e you must set y[0]==1 or whatever with 2 = signs if not
you need to clear these variables or restart the kernel.
for ex. to ask it to solve dy/dx=2y
DSolve[y'[x]==2y[x],y[x],x]
it gives y[x]-> e^{2x}C(1)
you can also add initial conditions:
DSolve[{y''[x]==2y'[x]+4y[x],y[0]==1,y'[0]==2},y[x],x]
For plotting direction fields or slope fields you need to first input:
<<Graphics`PlotField`
{note you add the < < marks and note the backwards tick marks `
not single quotes '}
{This will load the special graphics programs}
Then to plot the direction field for (dy/dx)=x^2+y^2 use the command:
PlotVectorField[{1,x^2+y^2},{x,-2,2},{y,-2,3}]
{note the shape of the brackets everywhere, the use of the commas and
the mysterious 1 before x^2+y^2- in general if you want dy/dx=f(x,y)
then the command is PlotVectorField[{1,f(x,y)},{x,-2,2},{y,-2,3}]
this is because it thinks of this as two partial derivatives}
Here is what I got

To plot the vector field and a particular solution- you can either do
them separately- i.e. plot the vector field, solve the de. then plot
the solution with an initial condition (ie.something like
Plot[5E^(2x)-3E^(-2x), {x,0,10}] or you can plot a bunch of functions
like Plot[{5E^x,-2E^x, Sin[x]}, {x,0,10}] and it will plot all of them
on the same graph).
Or as we discussed today (10/8) you can use the Show command- so far
this is the best I have for this- if anyone can do it more simply
please let me know: say we want to graph a few solutions of the DE
y'=4y on the direction field. First we solve the equation and name it
something (be careful if you screw this up you may need to clear the
variable name each time you make a mistake)
DSolve[y'[x]==4y[x],y,x] then you can do
Plot[{{y[x]/. %}/. C[1] -> 1, {y[x]/. %}/. C[1]->2, {y[x]/.
%}/. C[1] ->-3},{x,0,2}]
This involves some specdial notation the command y[x]/. $$$$
means let y[x] be $$$$ in this case we want y[x] to be the
function that arose in the DSolve command to refer to the previous line
in this we use % so y[x]/. % means let y[x] be the function that arose
in the previous command. Then there is another /. which is saying to
let the constant C[1] be replaced by 1 in the first function, 2 in the
second, and -3 in the third
More to come
Part II
Some Maple commands:
For Reduction of order - Maple: reduceOrder
Variation of Parameters- Maple: varparam
To Solve constant coefficient diff. eqs. - Maple: constcoeffsols
For Series solutions: in Maple here are some commands to look into
dsolve(ode,y(x),'formal_series','coeffs'='rational');
dsolve( {ode}, y(t), type=series);
For Wronskians:
A := vector([exp(x),cosh(x),sinh(x)]);
Wr := wronskian(A,x);
Higher derivatives: diff(f(x),x,x,x,x,x); would be the fifth
derivative of f(x) w.r.t. x
or diff(f(x),x$5); would do the same (thanks to I forget who for this
tip)
there is also an operator D which can only be applied to functions so I
do am not sure how to use it here- it is only for things like f:=
x-> exp(3*x); D(f); would be the first derivative and more generally
(D@@5)(f); would be the fifth derivative. I have not figured out how to
put this into a differential equation yet.
Some Mathematica Commands
DSolve seems to handle most of the differential equations in
Mathematica and I have not encountered specific other commands.
Also there is no special command for Wronskian calculations, so I
suspect that you need to input the functions and the derivatives into a
matrix then use the determinant command for that matrix: Det - you can
use the toolbar on the side to enter a matrix or you can use curly
brackets {{a,b,c},{d,e,f},{g,h,i}} represents the matrix with row 1
a,b,c and row 2, d,e,f row 3 g,h,i.
For Series solutions- it looks as though Mathematica will just give the
solutions in terms of integrals but the command Series[f, {x,x_0,n}] to
create a power series about the point x_0 (the rest of it tells
Mathematica that x is the variable and n is how many terms to compute).
To compute Wronskians more easily:
Wronskian[f__, x_] := Det[NestList[D[#, x] &, f, Length[f] - 1]]
Then you can do them more quicly using:
FullSimplify[Wronskian[{f[x],g[x],h[x]},
x]]
Or for more functions as well.
You can go directly
to series solutions from the diff. eq. such as:
Series[y''''+(x^2)y'''-3x*y''+Sin[x]y'+y==0, {x,1,10}]
or with an initial condition:
Series[{y''''+(x^2)y'''-3x*y''+Sin[x]y'+y==0,
y[1]==2,y'[1]==-3,y''[1]==5, y'''[1]==0}, {x,1,10}]