★ wanayoo — archive 1999 http://www.maplesoft.com/apps/categories/maple_tools/functionality/html/odes1.htmlNouvelle recherche | Portail wanayoo

Solving Ordinary Differential Equations Using Maple

© 1998 Waterloo Maple Inc.

NOTE: This worksheet is a comprehensive introduction to Maple's capabilities with Differential Equations.

Initializing Maple to Work with Differential Equations

Many routines for working with odes (and PDEs) are contained in the Maple package, DEtools. This should normally be loaded into memory using the 'with' command.

> restart:
> with(DEtools);

[DEnormal, DEplot, DEplot3d, DEplot_polygon, DFactor, Dchangevar, GCRD, LCLM, PDEchangecoords, RiemannPsols, abelsol, adjoint, autonomous, bernoullisol, buildsol, buildsym, canoni, chinisol, clairautsol, constcoeffsols, convertAlg, convertsys, dalembertsol, de2diffop, dfieldplot, diffop2de, eigenring, endomorphism_charpoly, equinv, eta_k, eulersols, exactsol, expsols, exterior_power, formal_sol, gen_exp, generate_ic, genhomosol, hamilton_eqs, indicialeq, infgen, integrate_sols, intfactor, kovacicsols, leftdivision, liesol, line_int, linearsol, matrixDE, matrix_riccati, moser_reduce, mult, newton_polygon, odeadvisor, odepde, parametricsol, phaseportrait, poincare, polysols, ratsols, reduceOrder, regular_parts, regularsp, riccati_system, riccatisol, rightdivision, separablesol, super_reduce, symgen, symmetric_power, symmetric_product, symtest, transinv, translate, untranslate, varparam, zoom]

Entering Equations

A. First Order odes :

> diff(y(t),t)+y(t)+x(t)=0;

[Maple Math]

> diff(y(t),t)-y(t)=sin(t);

[Maple Math]

B. Higher Order odes :

> m*diff(y(t),t$2)+b*diff(y(t),t)+k*y(t)=0;

[Maple Math]

> diff(y(t),t$4)-10*diff(y(t),t$3)+35*diff(y(t),t$2)-50*y(t)+24=5*exp(t);

[Maple Math]

Solving

A. Single Equations

Example 1 - Response of a Parallel RLC Circuit

> R:=10000 : L:=0.001: C:=0.000001:
> diff(V(t),t$2) + (1/(R*C))*diff(V(t),t) + V(t)/(L*C) = 0;

[Maple Math]

A general solution is found using:

> dsolve(%, V(t), method=laplace);

[Maple Math]
[Maple Math]

A particular solution can be found using initial values for V and dV/dt.

> dsolve({%%, V(0)=10, D(V)(0)=1}, V(t), explicit=true);

[Maple Math]

Example 2 - Bessel Equation and Series Solution

> x^2*diff(y(t),t$2) + x*diff(y(t),t) + (x^2-1)*y = 0;

[Maple Math]

> dsolve({%, y(0)=0, D(y)(0)=1}, y(t), type=series);

[Maple Math]

Example 3 - Numerical Solution

> diff(y(t),t$2) + sin(t)*y(t) = 0;

[Maple Math]

> soln := dsolve({%, y(0)=2, D(y)(0)=-2}, y(t), type=numeric);

[Maple Math]

> soln(0); soln(Pi/2); soln(Pi); soln(3*Pi/2);

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

B. Systems

Example 4

> interface(labelling=false): eqn1 := diff(y(t),t) = z(t) - y(t); eqn2 := diff(z(t),t) = y(t);

[Maple Math]
[Maple Math]

> soln := dsolve({eqn1, eqn2, y(0)=0, z(0)=1}, {y(t), z(t)}):
> collect(soln,exp);

[Maple Math]
[Maple Math]

Plotting Differential Equations

A. Single Equations - Damped Oscillator Model

> eqn5 := m*diff(x(t),t$2) = -b*diff(x(t),t) - k*x(t);
m:=0.5: b:=1: k:=20:

> DEplot(eqn5, {x(t)}, 0..5, [[x(0)=5, D(x)(0)=-2]],
title=`Damped Oscillator`);

[Maple Math]
[Maple Plot]

B. Systems of Equations - Dynamical System Model

> eqn5 := diff(y(t),t)=-y(t)-x(t);

[Maple Math]

> eqn6 := diff(x(t),t)=y(t);

[Maple Math]

> ic1 := x(0)=0, y(0)=5;
> ic2 := x(0)=0, y(0)=-5;

[Maple Math]
[Maple Math]

> DEplot({eqn5,eqn6}, [x(t),y(t)], -5..5, [[ic1],[ic2]], title=`Spiral`);

[Maple Plot]

Phase Portraits

> eqn3 := diff(y(x),x)=-y(x)-x^2;

[Maple Math]

> phaseportrait(eqn3, y(x), x=-1..2.5,
[[y(0)=0],[y(0)=1],[y(0)=-1]], title=`Asymptotic Solution`,
color=magenta, linecolor=[red,blue,green]);

[Maple Plot]