unit08.mws

ORDINARY DIFFERENTIAL EQUATIONS POWERTOOL

Unit 8 -- Exact Equations

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 8

>

Initialization

> restart;

> with( DEtools ):

> with( plots ):

> with( linalg ):

Warning, the name changecoords has been redefined

Warning, the name adjoint has been redefined

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

>

8.A Basic Theory

The general form for a first-order exact differential equation is

> gen_exact_ode := P(x,y(x)) + Q(x,y(x))*diff(y(x),x) = 0;

gen_exact_ode := P(x,y(x))+Q(x,y(x))*diff(y(x),x) =...

>

The special property of exact equations is that the left-hand side of the ODE can be written as an ``exact derivative''. In this case, there is a function F=F(x,y) such that level curves of F,

> level_curve := F(x,y(x)) = C;

level_curve := F(x,y(x)) = C

>

for some constant C , gives an implicit solution to the differential equation.That is, the function F = F(x,y) satisfies the

> condition_to_be_exact := collect( diff( lhs(level_curve), x ) - lhs( gen_exact_ode ) = 0, diff(y(x),x) );

condition_to_be_exact := (D[2](F)(x,y(x))-Q(x,y(x))...

>

Careful consideration of this equation shows that it is satisfied when

> condition1 := isolate( eval( condition_to_be_exact, diff(y(x),x)=0 ), F );

> condition2 := isolate( coeff( lhs(condition_to_be_exact), diff(y(x),x) ) = 0, F );

condition1 := D[1](F)(x,y(x)) = P(x,y(x))

condition2 := D[2](F)(x,y(x)) = Q(x,y(x))

>

That is, when

Diff(F,x) = P and Diff(F,y) = Q .

For arbitrary pairs of functions P and Q, this condition will not be satisfied. However, assuming the function F has continuous second derivatives and the functions P and Q have continuous first derivatives, the equivalence of the mixed second derivatives of F

> equiv_of_mixed_deriv := D[1](D[2](F)(x,y(x))) = D[2](D[1](F)(x,y(x)));

equiv_of_mixed_deriv := D[1](D[2](F)(x,y(x))) = D[2...

>

combines with the previous argument

> q1 := D[2](condition1);

> q2 := D[1](condition2);

q1 := D[2](D[1](F)(x,y(x))) = D[2](P(x,y(x)))

q2 := D[1](D[2](F)(x,y(x))) = D[1](Q(x,y(x)))

>

to provide necessary and sufficient conditions for an exact equation:

> eval( equiv_of_mixed_deriv, [ D[2](condition1), D[1](condition2) ] );

D[1](Q(x,y(x))) = D[2](P(x,y(x)))

>

That is,

> nec_and_suff_condition := (P,Q) -> diff( Q(x,y), x ) = diff( P(x,y), y ):

> nec_and_suff_condition(P,Q);

diff(Q(x,y),x) = diff(P(x,y),y)

>

8.A-1 Example 1

Consider the differential equation

> ode := exp(y(x)) + (x*exp(y(x))+cos(y(x))) * diff(y(x),x) = 0;

ode := exp(y(x))+(x*exp(y(x))+cos(y(x)))*diff(y(x),...

>

To check if this ODE is exact, identify the coefficients for the general form

> P := unapply( eval( lhs(ode), [diff(y(x),x)=0, y(x)=y] ), (x,y) );

> Q := unapply( eval( coeff(lhs(ode),diff(y(x),x)), y(x)=y ), (x,y) );

P := proc (x, y) options operator, arrow; exp(y) en...

Q := proc (x, y) options operator, arrow; x*exp(y)+...

>

and check the necessary and sufficient condition for exactness:

> nec_and_suff_condition(P,Q);

exp(y) = exp(y)

>

Since this is an exact equation, we construct the solution in the form F(x,y) = C where Diff(F(x,y),x) = P(x,y) and Diff(F(x,y),y) = Q(x,y) . The first of these is satisfied when

> q1 := F(x,y) = int( P(x,y), x ) + g(y);

q1 := F(x,y) = x*exp(y)+g(y)

>

To satisfy the second condition requires

> q2 := diff( rhs(q1), y ) - Q(x,y) = 0;

q2 := diff(g(y),y)-cos(y) = 0

>

Thus,

> q3 := isolate( map( int, q2, y ), g(y) );

q3 := g(y) = sin(y)

>

and so

> soln_F := eval( rhs(q1), q3 );

soln_F := x*exp(y)+sin(y)

>

and the implicit solution of the differential equation is

> soln := soln_F = C;

soln := x*exp(y)+sin(y) = C

>

A quick pause to check that this solution does satisfy the differential equation reveals

> odetest( eval(soln,y=y(x)), ode );

0

>

The function F is also called a first integral of the ODE. The Maple command firint , from the DEtools package, can be used to express the solution of an exact ODE in terms of its first integral. For example,

> firint( ode );

x*exp(y(x))+sin(y(x))+_C1 = 0

>

Note that essentially the same solution is returned with either of the following single commands

> exactsol( ode, y(x) );

{x*exp(y(x))+sin(y(x))+_C1 = 0}

> dsolve( ode, y(x), [exact] );

x*exp(y(x))+sin(y(x))+_C1 = 0

>

The even simpler command

> infolevel[dsolve] := 3:

> dsolve( ode, y(x) );

> infolevel[dsolve] := 0:

Methods for first order ODEs:

Trying to isolate the derivative dy/dx...

Successful isolation of dy/dx

-> Trying classification methods

trying a quadrature

trying 1st order linear

trying Bernoulli

trying separable

trying inverse linear

1st order linear successful

inverse linear successful

x+exp(-y(x))*sin(y(x))-exp(-y(x))*_C1 = 0

>

returns an equivalent, but different, solution. This is because Maple is able to find several classifications for this example

> odeadvisor( ode );

[[_1st_order, _with_exponential_symmetries], _exact...
[[_1st_order, _with_exponential_symmetries], _exact...

>

and uses a different solution method.

>

8.B Integrating Factors

Most first-order ODEs are not exact. Some of these ODEs can be made exact by multiplying the ODE by an appropriate function so that the new ODE is exact. The integrating factor, mu(x,y) , must be chosen so that the necessary and sufficient condition is satisfied by the coefficients of the ODE after multiplication by mu(x,y) :

> unassign('P','Q','mu');

> nec_and_suff_condition( mu*P, mu*Q );

diff(mu(x,y),x)*Q(x,y)+mu(x,y)*diff(Q(x,y),x) = dif...

>

This is a partial differential equation, but there are numerous cases where the determination of the integrating factor can be completed under the assumption that mu is a function of either x or y , but not both. A key to getting a handle on this condition is to note when at least one of Diff(Q,x) and Diff(P,y) is zero.

>

8.B-1 Example 2

Consider the following example (and ignore the fact that it is a first-order linear ODE)

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

ode2 := x+y(x)-x*diff(y(x),x) = 0

>

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

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

P := proc (x, y) options operator, arrow; y*x-2 end...

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

> ode2 := P(x,y(x)) + Q(x,y(x)) * diff( y(x), x ) = 0;

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

That this equation is not exact can be seen from

> nec_and_suff_condition( P,Q );

2*x-y = x

>

or

> odeadvisor( ode2, [exact] );

[NONE]

>

An integrating factor, if one exists, must satisfy the partial differential equation

> mu_pde := nec_and_suff_condition( mu*P, mu*Q );

mu_pde := diff(mu(x,y),x)*(x^2-y*x)+mu(x,y)*(2*x-y)...

>

With a little inspection, it can be seen that this PDE simplifies to a linear ODE when the integrating factor is assumed to be independent of y :

> mu_ode := eval( mu_pde, mu(x,y)=mu(x) );

mu_ode := diff(mu(x),x)*(x^2-y*x)+mu(x)*(2*x-y) = m...

> mu_ode2 := simplify( isolate( mu_ode, diff(mu(x),x) ) );

mu_ode2 := diff(mu(x),x) = -mu(x)/x

>

The general solution to this separable (and linear) ODE is found to be

> mu_sol := dsolve( mu_ode2, mu(x) );

mu_sol := mu(x) = _C1/x

>

Since any (non-trivial) solution can be used as an integrating factor, choose _C1 =1 and define

> mu := unapply( eval( rhs(mu_sol), _C1=1 ), x );

mu := proc (x) options operator, arrow; 1/x end pro...

>

To confirm that this function is an integrating factor for the ODE,

> simplify( nec_and_suff_condition( mu*P, mu*Q ) );

1 = 1

>

and

> odeadvisor( mu(x)*ode2, [exact] );

[_exact]

>

The Maple command mutest , in the DEtools package, provides an alternate method for checking the validity of an integrating factor for a differential equation:

> mutest( mu(x), ode2 );

0

>

The intfactor command, also from the DEtools package, can be used as a black box to find an integrating factor. An integrating factor for this ODE is

> intfactor( ode2 );

1/x

>

The solution to this ODE is

> dsolve( mu(x)*ode2, y(x), [exact], implicit );

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

>

Note that without the optional argument implicit Maple returns the pair of solutions

> dsolve( mu(x)*ode2, y(x), [exact] );

y(x) = x+sqrt(x^2+2*_C1-4*ln(x)), y(x) = x-sqrt(x^2...

>

The specific solution obtained depends upon the specific initial condition.

The same solutions are also obtained from either of

> exactsol( ode2 );

{y(x) = x+sqrt(x^2+2*_C1-4*ln(x)), y(x) = x-sqrt(x^...

> dsolve( ode2, y(x), [exact] );

y(x) = x-sqrt(x^2+2*_C1-4*ln(x)), y(x) = x+sqrt(x^2...

>

In terms of first integrals, the original ODE is not exact so does not have a first integral

> firint( ode2 );

Error, (in ODEtools/firint) The given ODE is not exact

>

But, when multiplied by the integrating factor,

> q := firint( mu(x)*ode2 );

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

>

which simplifies to the implicit solution found above.

> simplify( q );

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

>

[Back to ODE Powertool Table of Contents]

>