Contents
Next

Differential Equations - Symbolic Solutions


Differential Equations of First Order

In a first step we write down the differential equation that we want to solve. Note the apostroph in front of the diff. It is needed to avoid the immediate computation of a derivative.

eq:'diff(y,x) = -y;

We obtain the equation in a more conventional writing form:

	 dy
      	 -- = - y
	 dx

We use ode2 to compute a solution:

ode2(eq, y, x);

The solution contains the integration constant %C.

	  - x
y = %c %e

To obtain a solution for a selected initial value we use the function ic1 to define the initial condition. For later use, we assign the solution to the variable sol:

sol: ic1(%, x= 1, y= 8);

This initial condition selects the solution that passes through point (1, 8). We obtain:

			 1 - x
(%o3)		 y = 8 %e

You can now draw the solution:

plot2d(rhs (sol),[x,-4,4],[y,-10,10]);

Differential Equations of Second Order

Like differential equations of first, order, differential equations of second order are solved with the function ode2. To specify an initial condition, one uses the function ic2, which specifies a point of the solution and the tangent to the solution at that point.

Example:

eq: 'diff(y, x, 2) + y = 0;

This is:

		     2
		    d y
(%o1)		    --- + y = 0
		      2
		    dx

The general solution is again computed with ode2:

sol2: ode2(eq, y, x);

We obtain:

(%o2)    y = %k1 sin(x) + %k2 cos(x)

This solution has two parameters. There are two substantially different ways to compute values for these parameters:

For the initial value problem we use the function ic2:

ps: ic2(sol2, x=0, y=2, 'diff(y, x)=1);
 y = sin(x) + 2 cos(x)

We check that the initial value is satisfied by this solution:

ev (rhs(ps) , x= 0);
 2 

We check that derivation of the solution satisfies the condition 'diff(y, x)=1:

 diff(rhs (ps), x);
 cos(x) - 2 sin(x)
 ev (%, x = 0);
 1 

We note that it is not possible to combine these two expressions into:

ev (diff(rhs(ps), x), x=0);

For the boundary value problem we use the function bc2:

bc2(sol2, x=0, y=2, x=2, y = -1);
	            (2 cos(2) + 1) sin(x)
     y = 2 cos(x) - ---------------------
                          sin(2)

It is easy to verify that both boundary conditions are satisfied by this solution:



Contents
Next