L-27 MCS 320 Friday 28 October 2005
| > | restart; |
The command dsolve is almost as popular in Maple as solve.
1. Symbolic Solution of differential equations
This is the purely symbolic solution of an differential equation, obtained by anti-differentiation:
| > | ODE := x*diff(y(x),x) = y(x)*ln(x*y(x)) - y(x); |
| > | sol := dsolve(ODE,y(x)); |
This is a first-order ODE, we derived only once with respect to x. The result is a family parametrized by the complex constant C1. To verify whether we have a solution, we substitute the solution into the ODE. Conveniently that the solution is an equation, because we can give this as first argument to subs:
| > | subs(sol,ODE); |
| > | simplify(%); |
This is a nice illustration of the normalization problem in symbolic computation.
2. Series Expansions to solve
If a symbolic solution does not exist as an explicit formula, we may still compute symbolically an approximate answer, using series.
| > | diffeq := L*diff(theta(t),t$2) = -g*sin(theta(t)); |
This ODE expresses the motion of a pendulum, made from a mass hanging from a string of length L, subject to the gravitation (constant g). In order to have a formal solution, we simplify sin(theta) = theta, for small values of theta.
We turn this problem into an Initial Value Problem (IVP) by the conditions
| > | inits := theta(0) = 0, D(theta)(0) = v[0]; |
The two initial conditions express that at t = 0, we have no deviation in the angle, but we have an initial velocity v[0]. Notice the introduction of the "D" operator, here we consider theta as a function, whereas in the differential equation, we use the "diff" operator.
| > | IVP := {diffeq,inits}; |
| > | sol := dsolve(IVP,theta(t),series); |
This is a formal solution, we see the parameters L, g, v[0] as symbols. But it is also an approximate solution, valid only for small values of t, t << 1.
3. Numerical Solutions
To illustrate the numerical option, we take another differential equation:
| > | diffeq := diff(y(t),t$2) - (1-y(t)^2)*diff(y(t),t) + y(t) = 0; |
| > | inits := y(0) = 0, D(y)(0) = -0.1; |
| > | IVP := {diffeq,inits}; |
| > | sol := dsolve(IVP,y(t),numeric); |
Maple returns a procedure, which we may evaluate, for any value of t, say t = 0:
| > | sol(0); |
On return we get a list of equations. First the value of t, then the position y(t), and then the velocity. Here we recognize our initial conditions.
| > | sol(1); |
To plot the solution, we often create an extra function:
| > | ysol := t -> rhs(sol(t)[2]); |
| > | ysol(1); |
| > | plot(ysol,0..20); |
![[Plot]](images/lec27_17.gif)
| > |
4. Graphical Solutions
We can plot a vector field of trajectories, for systems of first order equations.
See the handout to convert this problem into a system of two first order equations, introducting an extra variable yy(t) for diff(y(t),t).