Plotting a solution to a differential equation
sm311o_1.mws,wdj,1-9-98
> with(plots):
The first method is to explicitly solve the DE and then plot the function. Obviously, this will not work if MAPLE cannot solve the DE explicitly.
>
de:=diff(y(x),x$2)+2*diff(y(x),x)+2*y(x)=0;
The differential equation
>
ic:=D(y)(0)=0,y(0)=1;
The initial conditions
>
soln:=dsolve({de,ic},y(x),method=laplace);
The DE and IC need to be surrounded by curly brackets. The option
method=laplace
insures that the solution function will probably be expressed in the same form as if you solved it yourself by hand.
>
y0:=t->subs(x=t,rhs(soln)):
y0(x);
You have to (unfortunately) create a function - called y0 to distinguish it from the dependent variable y - in MAPLE from the solution
soln
using the arrow notation
->
and the substitution command
subs
. This is because MAPLE does not recognize the right hand side of the solution
rhs(soln)
as a function but sees it as a sequence of symbols.
> plot(y0(x),x=0..1);
The second method to plot the solution to a DE in MAPLE involves the plotting command odeplot . This method works even if MAPLE cannot solve the DE explicitly.
> numsoln:=dsolve({de,ic},y(x),type=numeric);
> odeplot(numsoln,[x,y(x)],0..1);
>
>