Solving Initial-Value Problems with MAPLE


MAPLE has a procedure dsolve which will solve initial-value problems. In some cases it is possible to obtain analytic solutions with this procedure but we are concerned with finding numeric solutions to initial-value problems. In this case, dsolve uses a fourth-order Runge-Kutta-Fehlberg method where the accuracy is controlled by the Digits parameter.

For our purposes, the basic command is

> dsolve(deqns, vars, numeric, options);

where:

- deqns is a set of ordinary differential equations plus initial conditions,

- vars is the variables to be solved for

and the only option we will use is

- value = xarray

where xarray is an array of floating point numbers at which the solution is to be obtained.


Example 1 - a first-order ordinary differential equation

The following MAPLE code will solve the first order ode

at steps of 0.1.

> ode1:= diff(y(x),x) = 2*x*y(x) + x;

> xarray1:= array([evalf(i/10)$i=1..10]);

> dsolve({ode1,y(0)=2},y(x),numeric,value=xarray1);

This produces a two-dimensional array of numerical solutions.


Example 2 - a second-order initial-value problem

To solve

at steps of 0.5 we can use the following code:

> ode2:=diff(y(x),x,x) +2*x*diff(y(x),x) - (x+1)*y(x) = x*x + 2;

> xarray2:=array([evalf(1 + i/2)$i=1..4]);

> dsolve({ode2,y(1)=2,D(y)(1)=-2},y(x),numeric,value=xarray2);