unit10.mws

ORDINARY DIFFERENTIAL EQUATIONS POWERTOOL

Unit 10 -- Substitution and Change of Variables

Prof. Douglas B. Meade

Industrial Mathematics Institute

Department of Mathematics

University of South Carolina

Columbia, SC 29208

URL: http://www.math.sc.edu/~meade/

E-mail: meade@math.sc.edu

Copyright © 2001 by Douglas B. Meade

All rights reserved

-------------------------------------------------------------------

>

Outline of Unit 10

>

Initialization

> restart;

> with( DEtools ):

> with( plots ):

Warning, the name changecoords has been redefined

> with( linalg ):

Warning, the name adjoint has been redefined

Warning, the protected names norm and trace have been redefined and unprotected

> with( PDEtools ):

>

10.A Example 1: Homogeneous Equations

A homogeneous differential equation has the general form

> ode1 := M(x,y(x)) + N(x,y(x)) * diff( y(x),x ) = 0;

ode1 := M(x,y(x))+N(x,y(x))*diff(y(x),x) = 0

>

where the functions M and N are both homogeneous of the same degree. That is, there exists a constant alpha such that M(t*x,t*y) = t^alpha*M(x,y) and N(t*x,t*y) = t^alpha*N(x,y) .

For example, consider

> M := (x,y) -> x^2+y^2;

M := proc (x, y) options operator, arrow; x^2+y^2 e...

> N := (x,y) -> x^2-x*y;

N := proc (x, y) options operator, arrow; x^2-y*x e...

>

which produce the differential equation

> ode1;

x^2+y(x)^2+(x^2-y(x)*x)*diff(y(x),x) = 0

>

To check that this is a homogeneous ODE, observe that

> `M(tx,ty)` = simplify( M(t*x,t*y) / M(x,y) ) * `M(x,y)`;

`M(tx,ty)` = t^2*`M(x,y)`

> `N(tx,ty)` = simplify( N(t*x,t*y) / N(x,y) ) * `N(x,y)`;

`N(tx,ty)` = t^2*`N(x,y)`

>

To find the general solution to this ODE, introduce the change of variables

> ch_of_var := y(x) = x * u(x);

ch_of_var := y(x) = x*u(x)

>

The ODE becomes

> q1 := dchange( ch_of_var, ode1, [u(x)] );

q1 := x^2+x^2*u(x)^2+(x^2-x^2*u(x))*(u(x)+x*diff(u(...

>

This simplifies to

> sep_ode1 := simplify( isolate( q1, diff(u(x),x) ) );

sep_ode1 := diff(u(x),x) = (1+u(x))/(x*(-1+u(x)))

>

which is easily seen to be a separable equation

> odeadvisor( sep_ode1 );

[_separable]

>

The (implicit) solution to this equation is

> sol_u := dsolve( sep_ode1, u(x), [separable], implicit );

sol_u := ln(x)-u(x)+2*ln(1+u(x))+_C1 = 0

>

Reversing the change of variables, the solution to the original ODE is

> sol_y := dchange( isolate(ch_of_var,u(x)), sol_u, [y(x)] );

sol_y := ln(x)-y(x)/x+2*ln(1+y(x)/x)+_C1 = 0

>

That this equation defines a solution is confirmed with

> odetest( sol_y, ode1 );

0

>

Note that Maple's builtin commands can be used to classify this ODE as homogeneous

> odeadvisor( ode1 );

[[_homogeneous, `class A`], [_1st_order, _with_line...

>

and to find the general solution

> expl_sol := genhomosol( ode1 );

expl_sol := {y(x) = -2*x*LambertW(-1/2*exp(-1/2)*_C...

>

except that most people are not familiar with the Lambert W function. To obtain the solution of this homogeneous ODE in an implicit form

> dsolve( ode1, y(x), [homogeneous], implicit );

y(x)/x-2*ln((x+y(x))/x)-ln(x)-_C1 = 0

>

which is seen to be equivalent to the previous solution.

>

10.B Example 2: Bernoulli Equations

A Bernoulli equation has the form

> diff( x(t), t ) = f(t) * x(t) + g(t) * x(t)^alpha;

diff(x(t),t) = f(t)*x(t)+g(t)*x(t)^alpha

>

for known functions f and g and a constant alpha (not equal to 0 or 1).

For example, consider the differential equation

> ode2 := diff( x(t), t ) = a * x(t) - b * x(t)^3;

ode2 := diff(x(t),t) = a*x(t)-b*x(t)^3

>

where a and b are real constants with a <> 0 . This is a Bernoulli equation with

> alpha := 3;

alpha := 3

>

To convert the Bernoulli equation into a first-order linear ODE, consider the substitution

> ch_of_var := x(t) = u(t)^(1/(1-alpha));

ch_of_var := x(t) = 1/(sqrt(u(t)))

>

The ODE for the new function u(t) is

> q1 := dchange( ch_of_var, ode2, [u(t)] );

q1 := -1/2*diff(u(t),t)/(u(t)^(3/2)) = a/(sqrt(u(t)...

>

which simplifies to

> lin_ode := simplify( isolate( q1, diff(u(t),t) ));

lin_ode := diff(u(t),t) = -2*a*u(t)+2*b

>

The solution to this linear ODE is

> lin_sol := dsolve( lin_ode, u(t), [linear] );

lin_sol := u(t) = b/a+exp(-2*a*t)*_C1

>

and the corresponding implicit solution for the original function x(t) is

> sol2 := dchange( isolate(ch_of_var,u(t)), lin_sol, [x(t)] );

sol2 := 1/(x(t)^2) = b/a+exp(-2*a*t)*_C1

>

To verify that this is a solution of the original ODE:

> odetest( sol2, ode2 );

0

>

The solution might be a little more useful in the form

> sol2a := map( u->simplify(1/u), sol2 );

sol2a := x(t)^2 = a/(b+exp(-2*a*t)*_C1*a)

>

Immediate access to the solution to this Bernoulli equations can be obtained with the single command:

> dsolve( ode2, x(t), [Bernoulli], implicit );

1/(x(t)^2)-b/a-exp(-2*a*t)*_C1 = 0

>

from which either of the above implicit solutions, or the explicit solution, can be derived.

The bernoullisol command yields the two branches of the square root that are solutions:

> bernoullisol( ode2 );

{x(t) = sqrt((b+exp(-2*a*t)*_C1*a)*a)/(b+exp(-2*a*t...

>

The choice of branch depends on the signs of a , b , and the initial condition.

>

10.C Example 3: Reduction to Separation of Variables

Any ODE of the form

> Diff( y, x ) = F( a*x + b*y + c );

Diff(y,x) = F(a*x+b*y+c)

>

with b <> 0 can be reduced to a separable ODE via the substitution u = a*x+b*y(x)+c .

For example,

> ode3 := diff( y(x), x ) = ( x+y(x)+ 2)^2;

ode3 := diff(y(x),x) = (x+y(x)+2)^2

>

is of the appropriate form with a = 1 , b = 1 , c = 2 , and F(z) = z^2 . Thus, the substitution

> ch_of_var := u(x) = x + y(x) + 2;

ch_of_var := u(x) = x+y(x)+2

>

leads to a differential equation for u(x) :

> u_ode := dchange( isolate(ch_of_var,y(x)), ode3, [u(x)] );

u_ode := diff(u(x),x)-1 = u(x)^2

>

which is easily seen to be separable

> odeadvisor( u_ode, [separable] );

[_separable]

>

The implicit general solution to this separable differential equation is

> u_sol := dsolve( u_ode, u(x), [separable], implicit );

u_sol := x-arctan(u(x))+_C1 = 0

>

The corresponding explicit solution is

> u_sol_expl := dsolve( u_ode, u(x), [separable] );

u_sol_expl := u(x) = tan(x+_C1)

>

Reversing the substitution to obtain the implicit general solution to the differential equation for y(x) :

> sol3 := dchange( ch_of_var, u_sol, [y(x)] );

sol3 := x-arctan(x+y(x)+2)+_C1 = 0

>

The corresponding explicit solution can be obtained from

> sol3_expl := isolate( sol3, y(x) );

sol3_expl := y(x) = tan(x+_C1)-x-2

>

Note that simply using

> dchange( ch_of_var, u_sol_expl, [y(x)] );

x+y(x)+2 = tan(x+_C1)

>

does not produce an explicit formula for the general solution. It is still necessary to use isolate , or something similar:

> isolate( dchange( ch_of_var, u_sol_expl, [y(x)] ), y(x) );

y(x) = tan(x+_C1)-x-2

>

That these functions are solutions to the original ODE is seen from

> odetest( sol3, ode3 );

0

> odetest( sol3_expl, ode3 );

0

>

Immediate access to the implicit and explicit solutions can be obtained using

> dsolve( ode3, y(x), implicit );

x-arctan(x+y(x)+2)-_C1 = 0

> dsolve( ode3, y(x) );

y(x) = -tan(-x+_C1)-x-2

>

10.D Example 4: Riccati Equations

A Riccati equation has the form

> diff( x(t), t ) = f(t) * x(t)^2 + g(t) * x(t) + h(t);

diff(x(t),t) = f(t)*x(t)^2+g(t)*x(t)+h(t)

>

for given functions f, g, and h. The solution of a Ricatti equation requires knowledge of a particular solution to the ODE.

For example, consider

> ode4 := diff( x(t), t ) = -x(t)^2 + 2*t*x(t) - t^2+5;

ode4 := diff(x(t),t) = -x(t)^2+2*t*x(t)-t^2+5

>

which has as one solution

> X := t-2;

X := t-2

>

That this is a solution is confirmed by

> odetest( x(t)=X, ode4 );

0

>

To solve a Riccati equation, define a new function u(t) such that,

> ch_of_var := u(t) = x(t) - X;

ch_of_var := u(t) = x(t)-t+2

>

This substitution translates the ODE for x(t) into one for the new function u(t) :

> ode_u := dchange( isolate(ch_of_var,x(t)), ode4, [u(t)] );

ode_u := diff(u(t),t)+1 = -(u(t)+t-2)^2+2*t*(u(t)+t...

>

which simplifies to

> bern_ode := collect( isolate( ode_u, diff(u(t),t) ), u(t) );

bern_ode := diff(u(t),t) = -u(t)^2+4*u(t)-(t-2)^2-t...

>

Upon inspection, this ODE is seen to be a Bernoulli equation

> odeadvisor( bern_ode, [Bernoulli] );

[_Bernoulli]

>

which has solution

> bern_sol := dsolve( bern_ode, u(t), [Bernoulli] );

bern_sol := u(t) = 4*1/(1+4*exp(-4*t)*_C1)

>

Reversing the substitution,

> sol4 := dchange( ch_of_var, bern_sol, [x(t)] );

sol4 := x(t)-t+2 = 4*1/(1+4*exp(-4*t)*_C1)

>

To check that this is a solution to the original ODE,

> odetest( sol4, ode4 );

0

>

Note that the original equation can be classified as a Riccati equation using

> odeadvisor( ode4, [Riccati] );

[_Riccati]

>

and solved in one step using either

> riccatisol( ode4 );

{x(t) = t+2-exp(-4*t)/(_C1+1/4*exp(-4*t))}

>

or

> dsolve( ode4, x(t), [Riccati] );

x(t) = t+2-exp(-4*t)/(_C1+1/4*exp(-4*t))

>

[Back to ODE Powertool Table of Contents]

>