Differential Equation Solving With DSolve
Differential Equation Solving With DSolve
For the latest updates and corrections to this manual: visit reference.wolfram.com For information on additional copies of this documentation: visit the Customer Service website at www.wolfram.com/services/customerservice or email Customer Service at info@wolfram.com Comments on this manual are welcomed at: comments@wolfram.com Content authored by: Devendra Kapadia
2008 Wolfram Research, Inc. All rights reserved. No part of this document may be reproduced or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior written permission of the copyright holder. Wolfram Research is the holder of the copyright to the Wolfram Mathematica software system ("Software") described in this document, including without limitation such aspects of the system as its code, structure, sequence, organization, look and feel, programming language, and compilation of command names. Use of the Software unless pursuant to the terms of a license granted by Wolfram Research or as otherwise authorized by law is an infringement of the copyright. Wolfram Research, Inc. and Wolfram Media, Inc. ("Wolfram") make no representations, express, statutory, or implied, with respect to the Software (or any aspect thereof), including, without limitation, any implied warranties of merchantability, interoperability, or fitness for a particular purpose, all of which are expressly disclaimed. Wolfram does not warrant that the functions of the Software will meet your requirements or that the operation of the Software will be uninterrupted or error free. As such, Wolfram does not recommend the use of the software described in this document for applications in which errors or omissions could threaten life, injury or significant loss. Mathematica, MathLink, and MathSource are registered trademarks of Wolfram Research, Inc. J/Link, MathLM, .NET/Link, and webMathematica are trademarks of Wolfram Research, Inc. Windows is a registered trademark of Microsoft Corporation in the United States and other countries. Macintosh is a registered trademark of Apple Computer, Inc. All other trademarks used herein are the property of their respective owners. Mathematica is not associated with Mathematica Policy Research, Inc.
Contents
Introduction to Differential Equation Solving with DSolve . . . . . . . . . . . . . . . . . . . . . . Classification of Differential Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ordinary Differential Equations (ODEs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Overview of ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . First-Order ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Linear Second-Order ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Nonlinear Second-Order ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Higher-Order ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Systems of ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lie Symmetry Methods for Solving Nonlinear ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7 11 11 12 24 33 36 42 50 55 55 56 66 70 70 71 76 76 77 82 85 89 89 90 94 98
The GenerateParameters Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Symbolic Parameters and Inexact Quantities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Is the Problem Well-Posed? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
DSolve@eqn,y@xD,xD
DSolve returns results as lists of rules. This makes it possible to return multiple solutions to an equation. For a system of equations, possibly multiple solution sets are grouped together. You can use the rules to substitute the solutions into other calculations.
This finds the general solution for the given ODE. A rule for the function that satisfies the equation is returned.
In[1]:=
x Out[2]= 9 C@1D=
A general solution contains arbitrary parameters C @iD that can be varied to produce particular solutions for the equation. When an adequate number of initial conditions are specified, DSolve returns particular solutions to the given equations.
Here, the initial condition y@0D == 1 is specified, and DSolve returns a particular solution for the problem.
In[3]:=
x Out[3]= 99y@xD ==
This plots the solution. ReplaceAll (.) is used in the Plot command to substitute the solution for y@xD.
In[4]:=
Out[4]=
4 3 2 1 -3 -2 -1 1 2
When the second argument to DSolve is specified as y instead of y@xD, the solution is returned as a pure function. This form is useful for verifying the solution of the ODE and for using the solution in further work. More details are given in "Setting Up the Problem".
eqn . sol
This solves a system of ODEs. Each solution is labeled according to the name of the function (here, x and y), making it easier to pick out individual functions.
In[8]:=
eqns = 8Ht ^ 2 + 1L * x '@tD - t * x@tD + y@tD - Sign@tD, Ht ^ 2 + 1L * y '@tD - x@tD - t * y@tD + t * UnitStep@tD, x@0D - 1 2, y@0D 2<; sol = DSolve@eqns, 8x, y<, tD
-1 + 4 t + 2 ! ArcTan@tD t 0 -t True
1
+2t
LogA1 + t2 E t 0 True F,
2 I1 + t2 M 4+t-2t ! y FunctionB8t<, 2 I1 + t M
2
ArcTan@tD t 0 -t True
+2
This substitutes a random value for the independent variable and shows that the solutions are correct at that point.
In[10]:=
Out[11]=
-10 -5 5 10
-1
DSolve@eqn,u@x,yD,8x,y<D
While general solutions to ordinary differential equations involve arbitrary constants, general
While general solutions to ordinary differential equations involve arbitrary constants, general solutions to partial differential equations involve arbitrary functions. DSolve labels these arbitrary functions as C @iD.
Here is the general solution to a linear first-order PDE. In the solution, C @1D labels an arbitrary function of
In[12]:=
-x+y xy
eqn = x ^ 2 * D@u@x, yD, xD + y ^ 2 * D@u@x, yD, yD - Hx + yL * u@x, yD; sol = DSolve@eqn 0, u, 8x, y<D
-x + y xy FF>>
This obtains a particular solution to the PDE for a specific choice of C @1D.
In[14]:=
Out[14]= -x y
Out[15]=
DSolve can also solve differential-algebraic equations. The syntax is the same as for a system of ordinary differential equations.
This solves a DAE.
In[16]:=
eqns = 8f ''@xD == g@xD, f@xD + g@xD == 3 Sin@xD, f@PiD == 1, f '@PiD == 0<; sol = DSolve@eqns, 8f, g<, xD
1 2 1 2 H-2 Cos@xD + 3 p Cos@xD - 3 x Cos@xD + 3 Sin@xDLF, H2 Cos@xD - 3 p Cos@xD + 3 x Cos@xD + 3 Sin@xDLF>>
g FunctionB8x<,
Simplify@eqns . solD
A plot of the solutions shows that their sum satisfies the algebraic relation f @xD + g@xD 3 Sin@xD.
In[19]:=
Out[19]=
-4 -2 2 4
-5
The author hopes that these Differential Equation Solving with DSolve tutorials will be useful in acquiring a basic knowledge of DSolve and also serve as a ready reference for information on more advanced topics.
Out[1]= ::y@xD
Out[2]= ::y@xD -
A differential equation is linear if the equation is of the first degree in y and its derivatives, and if the coefficients are functions of the independent variable.
This is a nonlinear second-order ODE that represents the motion of a circular pendulum. It is nonlinear because Sin@ y@ xDD is not a linear function of y@ xD. The Solve::ifun warning message appears because Solve uses JacobiAmplitude (the inverse of EllipticF) to find an expression for y@ xD.
In[3]:=
:y FunctionB8x<, 2 JacobiAmplitudeB
2 1 2
H6 + C@1DL Hx + C@2DL2 ,
12
This plots the solutions. The discontinuity in the graphs at x = -3 results from the choice of inverse functions used by Solve .
In[4]:=
Plot@8y@xD . sol@@1DD . 8C@1D - 1, C@2D 3<, y@xD . sol@@2DD . 8C@1D - 1, C@2D 3<<, 8x, - 5, 5<D
1.0 0.5
Out[4]=
-4
-2 -0.5 -1.0
It should be noted that sometimes the solutions to fairly simple nonlinear equations are only available in implicit form. In these cases, DSolve returns an unevaluated Solve object.
This nonlinear differential equation only has an implicit solution. The Solve::tdep messages can be ignored; they appear because Solve cannot find an explicit expression for y@ xD because non-algebraic functions (ArcTan and Log) are involved.
In[5]:=
Out[5]= SolveB
2 3
-2 + 2 ArcTanB 2
H2+3 xL K-2+
2+3 x -1+x+y@xD
-1+x+y@xD
F C@1D + H2 + 3 xL
2
4 3
Log@2 + 3 xD, y F
When the coefficients of a linear ODE do not depend on x, the ODE is said to have constant coefficients.
This is an ODE with constant coefficients.
In[6]:=
The previous equation is also homogeneous: all terms contain y or derivatives of y and its righthand side is zero. Adding a function of the independent variable makes the equation inhomogeneous. The general solution to an inhomogeneous equation with constant coefficients is obtained by adding a particular integral to the solution to the corresponding homogeneous equation.
Here, x2 is added to the right-hand side of the previous equation, making the new equation inhomogeneous. The general solution to this new equation is the sum of the previous solution and a particular integral.
Here, x2 is added to the right-hand side of the previous equation, making the new equation inhomogeneous. The general solution to this new equation is the sum of the previous solution and a particular integral.
In[8]:=
Out[8]= ::y@xD
When the coefficients of an ODE depend on x, the ODE is said to have variable coefficients. Since equations with variable coefficients that are rational functions of x have singularities that are easily classified, there are sophisticated algorithms available for solving them.
The coefficients of this equation are rational functions of x.
In[9]:=
sol = DSolve@8y ''@xD - HH1 xL - H3 H16 x ^ 2LLL * y@xD 0, y@1D 1, y '@1D 4<, y@xD, xD
1 8 -2-2
x
Out[9]= ::y@xD
J-11 4 + 19 4
N x14 >>
There is a close relationship between functions and differential equations. Starting with a function of almost any type, it is possible to construct a differential equation satisfied by that function. Conversely, any differential equation gives rise to one or more functions, in the form of solutions to that equation. In fact, many special functions from classical analysis have their origins in the solution of differential equations. Mathieu functions are one such class of special functions. Mathieu was interested in studying the vibrations of elliptical membranes. The eigenfunctions for the wave equation that describes this motion are given by products of Mathieu functions.
This linear second-order ODE with rational coefficients has a general solution given by Mathieu functions.
In[10]:=
The presence of ArcCos@tD in the previous solution suggests that the equation can be given a simpler form using trigonometric functions. This is the form in which these equations were introduced by Mathieu in 1868.
In[11]:=
10
This plots the surface for a particular product of solutions to this equation.
In[12]:=
Plot3DBMathieuCB5, -
3 2
, xF * MathieuSB5, -
3 2
Out[12]=
The degree of a differential equation is the highest power of the highest-order derivative in the equation.
This is a first-order ODE of degree 2.
In[13]:=
:y FunctionB8x<,
Out[14]= 2.0
1.5
0.2
0.4
0.6
0.8
1.0
The examples in this tutorial have focused on the classification of ODEs. The classification of PDEs is similar but more involved. PDEs can also be classified by linearity or nonlinearity, order, degree, and constant or variable coefficients. More important is the classification that identifies a PDE as hyperbolic, parabolic, or elliptic. These classifications are discussed in further detail in "Second-Order PDEs".
11
12
name of equation
general form
date of discovery
mathematician
Separable Homogeneous Linear first-order ODE Bernoulli Riccati Exact first-order ODE Clairaut Linear with constant coefficients Hypergeometric Legendre Bessel Mathieu Abel Chini
G. Leibniz G. Leibniz G. Leibniz James Bernoulli Count Riccati L. Euler A-C. Clairaut L. Euler L. Euler M. Legendre F. Bessel E. Mathieu N. H. Abel M. Chini
y HxL + PHxL yHxL ! QHxL y HxL + PHxL yHxL ! QHxL y HxL ! f HxL + gHxL yHxL + hHxL yHxL
1724 1734 1734 1743 1769 1785 1824 1868 1834 1924
!M !y
!N !x
with a1 constant
xH1 - xL y HxL + Hc - Ha + b + 1L xL y HxL a b yHxL ! 0 I1 - x2 M y HxL - 2 x y HxL + nHn + 1L yHxL = 0 x2 y HxL + x y HxL + Ix2 - n2 M y HxL = 0 y HxL + Ha - 2 q cosH2 xLL yHxL = 0 y HxL ! f HxL + gHxL yHxL + hHxL yHxL2 + k HxL yHxL3 y HxL ! f HxL + g HxL y HxL + h HxL y HxLn
Examples of ODEs belonging to each of these types are given in other tutorials (clicking a link in the table will bring up the relevant examples).
First-Order ODEs
Straight Integration
This equation is solved by simply integrating the right-hand side with respect to x.
In[1]:=
13
Here is a plot of the integral curves for different values of the arbitrary constant C @1D.
In[2]:= In[3]:=
tab = Table@y@xD . sol@@1DD . 8C@1D -> k<, 8k, - 80, 80, 40<D; Plot@Evaluate@tabD, 8x, 3, 18<D
400
300
200
Out[3]=
100
6 -100
10
12
14
16
18
Separable Equations
The general solution to this equation is found by separation of variables.
In[1]:=
DSolveBy @xD
x2 y@xD ^ 2 3 - x2
, y, xF
2
F>>
x 3
3-x
- 3 ArcSinB
F - 2 C@1D
Even when variables can be separated, the final solution might be accompanied by a warning message from Solve , or it might only be given as an InverseFunction object.
Solving this ODE generates a warning message because Solve obtains an expression for y@xD using Log, the inverse of Exp. This warning message can be ignored.
In[2]:=
DSolveBy @xD
x2 Exp@y@xDD 3 - x2
, y, xF
Solve::ifun : Inverse functions are being used by Solve , so some solutions may not be found; use Reduce for complete solution information.
Out[2]= ::y FunctionB8x<, -LogB
1 2
3 - x2 -
3 2
ArcSinB
x 3
F - C@1DFF>>
14
The solution to this equation is given as an InverseFunction object, in order to get an explicit expression for y@xD.
In[3]:=
x2 Log@y@xDD * Sin@y@xDD
, y@xD, xF
InverseFunction::ifun : Inverse functions are being used. Values may be lost for multivalued inverses. InverseFunction::ifun : Inverse functions are being used. Values may be lost for multivalued inverses. Solve::tdep : The equations appear to involve the variables to be solved for in an essentially non-algebraic way.
Out[3]= ::y@xD InverseFunction@CosIntegral@1D - Cos@1D Log@1D &DB
1 2
-3 + x x
3 + x + 9 ArcSinhB
-3 + x 6
F + C@1DF>>
Homogeneous Equations
Here is a homogeneous equation in which the total degree of both the numerator and the denominator of the right-hand side is 2. The two parts of the solution list give branches of the integral curves in the form y = f HxL.
In[1]:=
This plots both branches together, showing the complete integral curves y2 ! C @1D x6 + several values of C @1D.
In[3]:= In[4]:= In[5]:=
x2 2
for
tab1 = Table@y@xD . sol@@1DD . C@1D k, 8k, 0, 3, 0.5<D; tab2 = Table@y@xD . sol@@2DD . C@1D k, 8k, 0, 3, 0.5<D; Plot@Evaluate@Join@tab1, tab2DD, 8x, 0, 1.7<D
Out[5]=
0.5 -2
1.0
1.5
-4
If an initial condition is specified, DSolve picks the branch that passes through the initial point. The DSolve::bvnul message indicates that one branch of the general solution (the lower
15
If an initial condition is specified, DSolve picks the branch that passes through the initial point. The DSolve::bvnul message indicates that one branch of the general solution (the lower branch in the previous graph) did not give a solution satisfying the given initial condition y@1D 3.
In[6]:=
Out[6]= ::y@xD
>> 2
Out[1]= ::y@xD
C@1D +
- 2
x2 2
p 2
ErfiB
3+x 2
F>>
Here is the solution for a more general linear first-order ODE. The K variables are used as dummy variables for integration. The Erfi term in the previous example comes from the integral in the second term of the general solution as follows.
In[2]:=
A more traditional form of the solution can be obtained by replacing K@1D with a variable such as t.
In[3]:=
16
Out[1]= SolveBx
y@xD2
C@1D +
- 2
y@xD2 2
p 2
ErfiB
3 + y@xD 2
F, y@xDF
Bernoulli Equations
A Bernoulli equation is a first-order equation of the form y HxL + PHxL yHxL ! QHxLyHxLn . The problem of solving equations of this type was posed by James Bernoulli in 1695. A year later, in 1696, G. Leibniz showed that it can be reduced to a linear equation by a change of variable.
Here is an example of a Bernoulli equation.
In[1]:=
In[2]:=
sol = DSolve@eqn, y, xD
11 1 + 11 x2 + 121 11 x C@1D
2
F>, :y FunctionB8x<,
11 1 + 11 x2 + 121 11 x C@1D
2
F>>
In general, the solution to a Bernoulli equation will consist of n - 1 branches, where n is the degree of yHxL in the equation.
17
Here is an example of a Bernoulli equation with n = 5. The solution has four branches.
In[4]:=
Out[4]= ::y@xD -
>, :y@xD -
>,
>, :y@xD
>>
14
Riccati Equations
A Riccati equation is a first-order equation of the form y HxL ! f HxL + gHxL yHxL + hHxL yHxL2 . This equation was used by Count Riccati of Venice (1676|1754) to help in solving second-order ordinary differential equations. Solving Riccati equations is considerably more difficult than solving linear ODEs.
Here is a simple Riccati equation for which the solution is available in closed form.
In[1]:=
Out[1]= ::y@xD -
Any Riccati equation can be transformed to a second-order linear ODE. If the latter can be solved explicitly, then a solution for the Riccati equation can be derived.
Here is an example of a Riccati equation and the corresponding second-order ODE, which is Legendres equation.
In[2]:=
DSolve@u '@xD HH2 xL H1 - x ^ 2LL * u@xD - HH15 4L H1 - x ^ 2LL - u@xD ^ 2, u@xD, xD Simplify
5 3 5 , xF + C@1D LegendrePB , xF - x LegendreQB , xF + LegendreQB , xF 2 2 2 2 3 3 2 I-1 + x2 M C@1D LegendrePB , xF + LegendreQB , xF >> 2 2 3
In[3]:=
18
Finally, consider the following Riccati equation. It is integrable because the sum of the coefficients of the terms on the right-hand side is 0.
In[4]:= In[5]:= In[6]:=
Out[6]= 0
In[7]:=
sol = DSolve@eqn, y, xD
-5 x-3 x C@1D +
1 12
2
F>> 3 p ErfB
5+6 x 2 3
-6
-x H5+3 xL
+5
2512
Out[8]= 8True<
Exact Equations
Here is an example of an exact ODE.
In[1]:= In[2]:= In[3]:=
P@x_, y_D := - H5 x ^ 2 - 2 y ^ 2 + 11L Q@x_, y_D := HSin@yD + 4 x * y + 3L Simplify@D@P@x, yD, yD - D@Q@x, yD, xDD
Out[3]= 0
In[4]:=
Out[4]= y @xD
In[5]:=
Out[5]= SolveB-11 x -
5 x3 3
19
Out[7]=
If an equation is not exact, it may be possible to find an integrating factor (a multiplier for the functions P and Q, defined previously) that converts the equation into exact form. DSolve tries a variety of techniques to automatically find integrating factors in such situations.
Clairaut Equations
A Clairaut equation is a first-order equation of the form yHxL ! x y HxL + f Hy HxLL. A remarkable feature of this nonlinear equation is that its general solution has a very simple form.
20
This is an example of a Clairaut equation. The warning message from Solve can be ignored. It is given because DSolve first tries to find an expression for y @xD from the given ODE.
In[1]:=
Out[2]=
2
2 -2
Abel Equations
An Abel ODE is a first-order equation of the form y HxL ! f HxL + gHxL yHxL + hHxL yHxL2 + kHxL yHxL3 . This equation arose in the context of the studies of Niels Henrik Abel on the theory of elliptic functions, and represents a natural generalization of the Riccati equation. Associated with any Abel ODE is a sequence of expressions that is built from the coefficients of the equation 8 f0 , f1 , f2 , f3 < and invariant under certain coordinate transformations of the independent variable and the dependent variable. These invariants characterize each equation and can be used for identifying integrable classes of Abel ODEs. In particular, Abel ODEs with zero or constant invariants can be integrated easily and constitute an important integrable class of these equations.
21
Here is the construction of a particular invariant with value 0 and the solution of the corresponding Abel ODE.
In[1]:=
f0 = 0; f1 =
1 x
; f2 = - 3; f3 = x; 1 3 2 f23 9
In[2]:=
Invariant = f0 f32 +
- f1 f3 f2 - !x f3 f2 + f3 !x f2
Out[2]= 0
In[3]:=
Out[3]= y @xD
In[4]:=
sol = DSolve@AbelODE, y, xD
1 x x2 1 x2
1 + C@1D
F>, :y FunctionB8x<,
1 x
+ x2
1 x2
1 + C@1D
F>>
In[5]:=
In[6]:=
Another important class of integrable Abel ODEs are those that can be reduced to inverse linear first-order ODEs using a nonlinear coordinate transformation.
This Abel ODE is solved by transforming it to an inverse linear first-order ODE. The ExpIntegralEi term in the solution to this equation comes from solving the linear ODE.
In[7]:=
x y@xD2 x-1
, y@xD, xF
InverseFunction::ifun : Inverse functions are being used. Values may be lost for multivalued inverses. InverseFunction::ifun : Inverse functions are being used. Values may be lost for multivalued inverses. Solve::tdep : The equations appear to involve the variables to be solved for in an essentially non-algebraic way.
1-x+
1 y@xD
Out[7]= SolveB
+ C@1D + ExpIntegralEiB1 - x +
1 y@xD
F 0, y@xDF
-1 + x
Another important class of integrable Abel ODEs consists of those that can be transformed to an inverse Riccati equation. Since Riccati equations can be transformed to second-order linear ODEs, the solutions for this class are usually given in terms of special functions such as AiryAi and BesselJ .
This Abel ODE is solved by reducing it to an inverse Riccati equation.
22
AbelODE = y @xD ==
y@xD3 8 x2
y@xD3 8 x2
- y@xD2
In[9]:=
Out[9]= SolveB
C@1D + AiryAiPrimeB-
H-1L23 2 213 x
+ -H-2L13 x +
H-2L13 y@xD
F + AiryAiB-
H-1L23 2 213 x
+ -H-2L13 x +
2
H-2L13 y@xD
-H-2L13 x +
H-2L13 y@xD
AiryBiPrimeBH-2L13 y@xD
2
H-1L23 2 213 x
H-2L13 y@xD
F+
AiryBiB-
H-1L23 2 213 x
+ -H-2L13 x +
F -H-2L13 x +
0, y@xDF
The Abel ODEs considered so far are said to be of the first kind. Abel ODEs of the second kind are given by the following general formula. y HxL ! f HxL + gHxL yHxL + hHxL yHxL2 + kHxL yHxL3 aHxL + bHxL yHxL
An Abel ODE of the second kind can be converted to an equation of the first kind with a coordinate transformation. Thus, the solution methods for this kind of Abel ODE are identical to the methods for equations of the first kind.
23
Here is the solution for an Abel ODE of the second kind. In[11]:=
2x 9
Solve::tdep : The equations appear to involve the variables to be solved for in an essentially non-algebraic way. Solve::tdep : The equations appear to involve the variables to be solved for in an essentially non-algebraic way.
2 3x 2 y@xD x2
2 1 2 3 4 3 2 2 3x 2 y@xD x2 2 14 2 3x 2 y@xD x2 2 14
Out[11]= SolveBC@1D -1 +
3x 2
Hypergeometric2F1B , -
, y@xDF 2 12 3x
2 y@xD x2
+ x3 >>
y@xD
Chini Equations
Chini equations are a generalization of Abel and Riccati equations.
This solves a Chini equation.
In[1]:=
Ix43 M
14
y@xDF &F
Log@xD , y@xDF
24
Notice that the general solution is a linear combination of two exponential functions. The arbitrary constants C @1D and C @2D can be varied to produce particular solutions.
This is one particular solution to the equation.
In[2]:=
-6 x + 3 x Out[2]= 2
The exponents -6 and 1 in the basis 9-6 x , x = are obtained by solving the associated quadratic equation. This quadratic equation is called the auxiliary or characteristic equation.
This solves the auxiliary equation.
25
Solve@m ^ 2 + 5 m - 6 0, mD
The roots are real and distinct in this case. There are two other cases of interest: real and equal roots, and imaginary roots.
This example has real and equal roots.
In[4]:=
In[5]:=
3x 3x Out[5]= 2 + 3 x
In[7]:=
x2 CosB Out[7]= 2
15
10
Out[8]=
-0.4
-0.2
0.2
0.4
26
Out[1]= ::y@xD
The Legendre linear equation is a generalization of the Euler equation. It is an ODE of the form Hc x + d L2 y HxL + a Hc x + d L y HxL + b yHxL ! 0.
Here is an example of a Legendre linear equation.
In[2]:=
5 Log@1 + 3 xDF +
C@1D SinB
1 3
Out[2]= ::y@xD
H1 + 3 xL13
H1 + 3 xL13
a0 = 1; a1 = Log@xD;
27
Out[5]= True
In[6]:=
sol = DSolve@eqn, y, xD
x 1
x-x Log@xD C@2D + x-x Log@xD -K@1D+K@1D Log@K@1DD C@1D K@1DF>> Out[6]= ::y FunctionB8x<,
Out[7]= 8True<
In[8]:=
Here is a plot that shows the oscillatory behavior of the Airy functions for large negative values of x.
In[2]:=
0.2
0.1
Out[2]=
-0.1
-14.5
-14.0
-13.5
-13.0
-12.5
-12.0
-0.2
-0.3
The solution to this equation is given in terms of the derivatives of the Airy functions, AiryAiPrime and AiryBiPrime .
28
The solution to this equation is given in terms of the derivatives of the Airy functions, AiryAiPrime and AiryBiPrime .
In[3]:=
Here is the solution for Bessels equation with n = 4. Note that the solution is given in terms of Bessel functions of the first kind, BesselJ , as well as those of the second kind, BesselY .
In[4]:=
0.4
0.2
Out[5]=
2 4 6 8 10
-0.2
These special functions can be expressed in terms of elementary functions for certain values of their parameters. Mathematica performs this conversion automatically wherever it is possible.
These are some of these expressions that are automatically converted.
In[7]:=
Sin@xD , x
Out[7]= :
1 8
As a result of these conversions, the solutions of certain ODEs can be partially expressed in terms of elementary functions. Hermites equation is one such ODE.
Here is the solution for Hermites equation with arbitrary n.
29
With n set to 5, the solution is given in terms of polynomials, exponentials, and Erfi .
In[9]:=
Collect@Simplify@PowerExpand@ y@xD . DSolve@y ''@xD - 2 * x * y '@xD + 10 * y@xD 0, y@xD, xD@@1DDDD, 8C@1D, C@2D<D
1 8 I960 x - 1280 x3 + 256 x5 M C@1D + 1 8 C@2D J8 x - 18 x x2 + 4 x x4 +
2 2 2
Out[9]=
p x I-15 + 20 x2 - 4 x4 M Erfi@xDN
DSolve can solve a large class of second-order linear ODEs by reducing them to the ODEs for hypergeometric functions. The reduction involves coordinate transformations of both the independent and dependent variables.
This equation is equivalent to the ODE for Hypergeometric2F1.
In[2]:=
4
Out[2]= ::y FunctionB8x<,
H-2 Log@-1+xD-Log@xDL
C@1D Hypergeometric2F1B- , - , - , xF
8 8 4
H-1L14 4
H-2 Log@-1+xD-Log@xDL
18
64 x2 Hx - 1L2 y ' '@xD + 32 x Hx - 1L H3 x - 1L y '@xD + H5 x - 21L y@xD . sol@@1DD . 8x RandomComplex@D< Simplify Chop
Out[3]= 0
Solutions to this equation are returned in terms of HypergeometricU (the confluent hypergeometric function) and LaguerreL. This example appears on (equation 2.16, page 403 of [K59]).
30
Solutions to this equation are returned in terms of HypergeometricU (the confluent hypergeometric function) and LaguerreL. This example appears on (equation 2.16, page 403 of [K59]).
In[4]:=
Out[4]= 2 2+2 c
-c ,
C@1D HypergeometricUB-
c 1+c
a x1+c
2
-c , -
F + C@2D LaguerreLB
1 1+c
a x1+c
2
2+2c
-H1 + cL
2+2c
-H1 + cL
The ODEs for special functions have been studied since the eighteenth century. During the last thirty years, powerful algorithms have been developed for systematically solving ODEs with rational coefficients. An important algorithm of this type is Kovacics algorithm, a decision procedure that either generates a solution for the given ODE in terms of Liouvillian functions or proves that the given ODE does not have a Liouvillian solution.
This equation is solved using Kovacics algorithm.
In[5]:=
Out[5]= ::y@xD
C@1D +
1 2
5 x3 3
x2 C@2D>>
The solution returned from Kovacics algorithm may occasionally include functions such as ExpIntegralEi or an unevaluated integral of elementary functions because, while it is easy to find a second solution for a second-order linear ODE once one solution is known, the integral involved in finding the second solution may be hard to evaluate explicitly.
The solution to this equation is obtained using Kovacics algorithm. It includes ExpIntegralEi .
In[6]:=
FN >>
Out[6]= ::y@xD
-7 x4
C@1D 32 x2
In general, the solutions for linear ODEs with rational coefficients and order greater than one can be given in terms of DifferentialRoot objects. This is similar to the representation for solutions of polynomial equations in terms of Root .
31
In[9]:=
1.0
Out[9]=
0.5
-1.0
-0.5 -0.5
0.5
1.0
This equation (equation 2.437, page 507 of [K59]) has trigonometric coefficients. The solution is given in terms of elementary functions.
In[2]:=
+ C@1D Cos@xD
- +
2
13 2
F>>
Here is an equation with a hyperbolic function in the coefficient of y@xD. The solution is given in terms of Legendre functions.
32
Here is an equation with a hyperbolic function in the coefficient of y@xD. The solution is given in terms of Legendre functions.
In[3]:=
-b + 2
d -2 2b
, 1+ l
2 b
d -b x b
F+
d -b x +
C@2D LaguerreLB
-b + 2
d -2 2b
2 b
d b
-b x
FF>>
Out[6]= 0
Out[1]= ::y@xD
3 Log@xDF
>>
Out[2]= ::y@xD
Different particular solutions can be obtained by varying the constants C @1D and C @2D in the solution.
33
Different particular solutions can be obtained by varying the constants C @1D and C @2D in the solution.
In[3]:=
particularsolutions = Flatten@Table@y@xD . sol . 8C@1D i, C@2D j<, 8i, 0, 5, 3<, 8j, 1, 3<DD
x SinB 1 2 2 x SinB 1 2 3 x SinB 1 2 3 3 1 3 3 x SinB x CosB x CosB 1 2 1 2 x2 CosB 1 2 1 2 3 Log@xDF + 1 3
2
Out[3]= :
3 Log@xDF +
1 3
x2 CosB 1 3
1 2
3 Log@xDF + x2 SinB 1 2
2
1 2
3 Log@xDF 1 2
,
2
3 Log@xDF +
x2 CosB x2 CosB 1 2
3 Log@xDF + x2 SinB
2
3 Log@xDF
2
3 Log@xDF +
1 3
1 2
3 Log@xDF + x2 SinB 1 3
1 2
3 Log@xDF
2
, 1 2
2
3 Log@xDF + 3 Log@xDF + 2
x SinB
3 Log@xDF + 1 2
x2 CosB
1 2
3 Log@xDF + x2 SinB
3 Log@xDF
x SinB 1 2
3 Log@xDF +
2
3 Log@xDF + x2 SinB
3 Log@xDF 1 2
, 3
2
x CosB 1 2
1 2
3 Log@xDF +
2
x2 CosB
3 Log@xDF + x2 SinB
3 Log@xDF
>
In[4]:=
Out[4]=
2
1.0
1.5
2.0
34
There are a few classes of nonlinear second-order ODEs for which solutions can be easily found. The first class consists of equations that do not explicitly depend on yHxL; that is, equations of the form y HxL = f Hx, y HxLL. Such equations can be regarded as first-order ODEs in uHxL = y HxL.
Here is an example of this type.
In[1]:=
As in the case of linear second-order ODEs, the solution depends on two arbitrary parameters C @1D and C @2D.
Here is a plot of the solution for a specific choice of parameters.
In[2]:=
-0.4
-0.2 -1
0.2
0.4
0.6
0.8
1.0
Out[2]=
-2
-3
Out[3]= 8True<
The second class of easily solvable nonlinear second-order equations consists of equations that do not depend explicitly on x or y HxL; that is, equations of the form y HxL ! f HyHxLL. These equations can be reduced to first-order ODEs with independent variable y. Inverse functions are needed to give the final solution for yHxL.
35
3 2
13
3 2
2 13
C@1D Hx + C@2DL2 F
2 13
F>,
:y@xD LogB
3 2
13
C@1D Hx + C@2DL2 F 3 2
F>,
2 13
:y@xD LogBH-1L23
C@1D Hx + C@2DL2 F
F>>
The third class consists of equations that do not depend explicitly on x; that is, equations of the form y HxL = f HyHxL, y HxLL. Once again, these equations can be reduced to first-order ODEs with independent variable y.
This example is based on (equation 6.40, page 550 of [K59]). The underlying first-order ODE is an Abel equation. The hyperbolic functions in the solution result from the automatic simplification of Bessel functions.
In[5]:=
sol = y@xD . DSolve@y ''@xD == 3 * y@xD * y '@xD + H3 y@xD ^ 2 + 4 * y@xD + 1L, y@xD, xD@@1DD Simplify
6 -2 x C@1D - 6 C@2D CoshB 3 2 3 2 3 2 3 2 -2 x C@1D F +
Out[5]=
-3 + 2
-2 x
-2 x
C@1D F
6 C@2D CoshB
-2 x
C@1D F + 3 SinhB
-2 x
C@1D F
The fourth class consists of equations that are homogeneous in some or all of the variables x, yHxL, and y HxL. There are several possibilities in this case, but here only the following simple example is considered.
In this equation, each term has a total degree of 2 in the variables y@xD, y @ xD, and y @ xD. This equation can be solved by transforming it to a first-order ODE.
In[6]:=
Out[6]= ::y@xD
The fifth and final class of easily solvable nonlinear second-order ODEs consists of equations that are exact or can be made to be exact using an integrating factor.
36
The fifth and final class of easily solvable nonlinear second-order ODEs consists of equations that are exact or can be made to be exact using an integrating factor.
Here is an example of this type, based on (equation 6.51, page 554 of [K59]).
In[7]:= In[8]:=
C@1D GammaB ,3
x3 3
x2
Out[8]= ::y@xD -
2 InverseErfB 3p
F>>
It is important to note that the solutions to fairly simple-looking nonlinear ODEs can be complicated. Verifying and applying the solutions in such cases is a difficult problem.
Higher-Order ODEs
Overview of Higher-Order ODEs
The general form of an ODE with order n is FIx, yHxL, y HxL, y" HxL, , yHnL HxLM = 0. As in the case of second-order ODEs, such an ODE can be classified as linear or nonlinear. The general form of a linear ODE of order n is a0 HxL yHnL HxL + a1 HxL yHn-1L HxL + + an HxL yHxL = bHxL. If bHxL is the zero function, the equation is said to be homogeneous. This discussion is primarily restricted to that case. Many methods for solving linear second-order ODEs can be generalized to linear ODEs of order n, where n is greater than 2. If the order of the ODE is not important, it is simply called a linear ODE.
37
The characteristic equation of this ODE has two pairs of equal roots: -3 and -5. The repeated roots give rise to the basis of the solutions, 93 x , x 3 x , 5 x , x 5 x =.
In[2]:=
The characteristic equation for this ODE has two pairs of roots with nonzero imaginary parts: 3 + 4 , 3 - 4 , 2 + , and 2 - . Hence the solution basis can be expressed with trigonometric and exponential functions.
In[3]:=
2x 3x 2x 3x Out[3]= 99y@xD C@2D Cos@xD + C@4D Cos@4 xD + C@1D Sin@xD + C@3D Sin@4 xD==
Finally, here is an example that combines all the previous kinds of solutions.
In[4]:=
DSolve@y '''''@xD - 17 * y ''''@xD + 108 * y '''@xD - 330 * y ''@xD + 488 * y '@xD - 280 * y@xD 0, y@xD, xD
-8 13 +14 &,1E
-8 13 +14 &,2E
C@2D +
C@3D + x
C@4D>>
The Legendre linear equation is a generalization of the Euler equation. It has the form
38
The Legendre linear equation is a generalization of the Euler equation. It has the form Hc x + d Ln yHnL HxL + a1 Hc x + d Ln-1 yHn-1L HxL + a2 Hc x + d Ln-2 yHn-2L HxL + an yHxL ! 0.
This is a Legendre linear equation.
In[2]:=
C@2D +
H5 + 3 xL
C@3D + H5 + 3 xL
C@4D>>
Out[6]= 0
39
sol = DSolve@ExactODE 0, y, xD
H-1L13 J
1 4
- 5 xN F C@2D + x2 AiryBiBKA2E 2
H-1L13 J
1 4
- 5 xN F C@3D +
523
1 4
523
H-1L13 K -5 K@2DO
H-1L
x2
13
1 4
- 5 xN
H-1L23
p AiryAiB513
AiryBiB-
523
F 1
523
F C@1D K@2D +
H-1L13 J AiryAiB-
1 4
- 5 xN F
x 1
H-1L23
KA1E 2
H-1L13 K -5 K@1DO
1 4
p AiryBiB513
523
523
Out[8]= 0
In[9]:=
2 2 Out[1]= 99y FunctionA8x<, AiryAi@2 + xD C@1D + AiryAi@2 + xD AiryBi@2 + xD C@2D + AiryBi@2 + xD C@3DE==
BesselJB
3 , xF C@1D + BesselJB
3 , xF BesselYB
3 , xF C@2D + BesselYB
3 , xF C@3DF>>
40
This plot shows the oscillatory behavior of the solutions on different parts of the real line.
In[3]:=
Show@8Plot@y@xD . sol1 . 8C@1D 2, C@2D 3, C@3D 1<, 8x, - 10, - 4<, PlotStyle 8Red<D, Plot@y@xD . sol2 . 8C@1D 2, C@2D 3, C@3D 1<, 8x, 2, 10<, PlotStyle 8Dashing@80.02<D, Blue<D<, PlotRange 88- 10, 10<, Automatic<D
0.6
0.5
0.4
Out[3]= 0.3
0.2
0.1
-5
10
HypergeometricPFQTypeEquation = 30 * x ^ 3 * y ''''@xD + 193 * x ^ 2 * y '''@xD + H219 * x - 30 x ^ 2L * y ''@xD + H21 - 90 xL * y '@xD - 30 y@xD; sol3 = DSolve@HypergeometricPFQTypeEquation 0, y, xD
H-1L23 C@1D HypergeometricPFQB:- >, :- , 1 3 5 6 11 15
>, xF +
7 9 41 , >, xF + x C@4D H-1L25 x25 C@3D HypergeometricPFQB: >, : 5 10 15 3 11 17 1 3 7 , >, xF + C@2D HypergeometricPFQB81, 1<, : , , >, xFF>> HypergeometricPFQB: >, : 2 10 6 2 5 3
x43
Out[6]= 0
As for second-order linear ODEs, there are modern algorithms for solving higher-order ODEs with rational coefficients. These algorithms give "rational-exponential" solutions, which are combinations of rational functions and exponentials of the integrals of rational functions. These algorithms are combined with techniques such as reduction of order to produce a complete solution for the given ODE.
41
The general solution to this equation has a rational term and terms that depend on Airy functions. The Airy functions come from reducing the order of the equation to 2.
In[7]:=
DSolve@HH6 - 24 * x + 4 * x ^ 2 - 10 * x ^ 3 + 9 * x ^ 4 - 4 * x ^ 5 + x ^ 6L * y@xDL HH- 1 + xL ^ 4 * x ^ 2L + HH- 8 + 30 * x - 10 * x ^ 2 + 10 * x ^ 3 - 3 * x ^ 4 - 2 * x ^ 5 + x ^ 6L * Derivative@1D@yD@xDL HH- 1 + xL ^ 3 * x ^ 2L + HH4 - 16 * x + 5 * x ^ 2 - 2 * x ^ 3L * Derivative@2D@yD@xDL HH- 1 + xL ^ 2 * x ^ 2L + HH4 - x ^ 2L * Derivative@3D@yD@xDL HH- 1 + xL * xL == 0, y, xD
H-1 + xL C@1D -4 + x2 + H-1 + xL AiryAi@xD C@2D -4 + x2 + H-1 + xL AiryBi@xD C@3D -4 + x2 F>>
The equations considered so far have been homogeneous; that is, with no term free of yHxL or its derivatives. If the given ODE is inhomogeneous, DSolve applies the method of variation of parameters to obtain the solution.
Here is an example of this type. The exponential terms in the solution come from the general solution to the homogeneous equation, and the remaining term is a particular solution (or particular integral) to the problem.
In[8]:=
This particular solution is part of the general solution to the inhomogeneous equation.
In[10]:= Out[10]=
Thus, the general solution for the inhomogeneous equation is the sum of the general solution to the homogeneous equation and a particular integral of the ODE. The solution methods for nonlinear ODEs of higher order rely to a great extent on reducing the problem to one of lower order.
42
Here is a nonlinear third-order ODE with no explicit dependence on x or y@xD. It is solved by reducing the order to 2 using a simple integration.
In[11]:=
Out[11]= ::y@xD -
Systems of ODEs
Introduction to Systems of ODEs
Systems of ODEs are important in various fields of science, such as the study of electricity and population biology. Like single ODEs, systems of ODEs can classified as linear or nonlinear. A system of linear first-order ODEs can be represented in the form X HtL ! AHtL X HtL +BHtL. Here X HtL is a vector of unknown functions, AHtL is the matrix of the coefficients of the unknown functions, and BHtL is a vector representing the inhomogeneous part of the system. In the two-dimensional case, the system can be written more concretely as x HtL ! pHtL xHtL + qHtL yHtL + uHtL y HtL ! rHtL xHtL + sHtL yHtL + vHtL. If all the entries of the matrix AHtL are constants, then the system is said to be linear with constant coefficients. If BHtL is the zero vector, then the system is said to be homogeneous. The important global features of the solutions to linear systems can be clarified by considering homogeneous systems of ODEs with constant coefficients.
43
In[3]:= In[4]:=
This solves the system. Note that the general solution depends on two arbitrary constants C @1D and C @2D.
In[5]:=
Here is a plot of some particular solutions obtained by giving specific values to C @1D and C @2D. In this case, the origin is a called a node.
In[6]:=
particularsols = Partition@Flatten@Table@8x@tD, y@tD< . sol . 8C@1D 1 i, C@2D 1 j<, 8i, - 20, 20, 6<, 8j, - 20, 20, 6<DD, 2D; ParametricPlot@Evaluate@particularsolsD, 8t, - 3, 3<, PlotRange -> 8- 2, 2<D
2
In[7]:=
Out[7]=
-2
-1
-1
-2
In this system the eigenvalues of the coefficient matrix are complex conjugates of each other.
In[8]:= In[9]:=
Out[9]= 81 + 2 , 1 - 2 <
In[10]:= In[11]:=
44
This plots the solution for various values of the arbitrary parameters. The spiraling behavior is typical for systems with complex eigenvalues.
In[13]:=
particularsols = Partition@Flatten@Table@8x@tD, y@tD< . sol . 8C@1D 1 i, C@2D 1 j<, 8i, - 10, 10, 8<, 8j, - 10, 10, 8<DD, 2D; ParametricPlot@Evaluate@particularsolsD, 8t, - 35, 35<, PlotRange All, PlotPoints 70, Method -> 8Compiled False<D
In[14]:=
1 1015
Out[14]=
-3 1015
-2 1015
-1 1015
1 1015
2 1015
3 1015
-1 1015
-2 1015
Solving homogeneous systems of ODEs with constant coefficients and of arbitrary order is a straightforward matter. They are solved by converting them to a system of first-order ODEs.
This solves a homogeneous system of ODEs of order 3, with constant coefficients.
In[15]:=
45
In[16]:=
3 t
C@3D Cos@tD + 2
3 t
3 t
Cos@tD +
3 t
Cos@tD - 2 Cos@tD - 2
3 t
Cos@2 tD + Cos@2 tD -
Sin@tD + Sin@tD +
3 t
3 t
3 t
3 t
- 3 t C@2D - 3 Cos@tD + 3 2 3 t Cos@tD - Sin@tD - 2 3 t Sin@tD - 2 3 t Sin@2 tD 192 1 - 3 t C@5D Sin@tD + 2 3 t Sin@tD - 3 t Sin@2 tD + 24 1 - 3 t C@4D - 3 Cos@tD + 3 2 3 t Cos@tD + Sin@tD + 2 3 t Sin@tD + 2 3 t Sin@2 tD F, 12 1 y FunctionB8t<, - 3 t C@5D Cos@tD + 2 3 t Cos@tD + 3 t Cos@2 tD 3 2 - 3 t C@4D Cos@tD + 2 3 t Cos@tD - 2 3 t Cos@2 tD + 3 Sin@tD - 3 2 3 t Sin@tD + 3 1 - 3 t C@2D Cos@tD + 2 3 t Cos@tD - 2 3 t Cos@2 tD - 3 Sin@tD + 3 2 3 t Sin@tD 24 1 - 3 t C@1D - 3 Cos@tD + 3 2 3 t Cos@tD - Sin@tD - 2 3 t Sin@tD - 2 3 t Sin@2 tD + 3 8 - 3 t C@3D Sin@tD + 2 3 t Sin@tD - 3 t Sin@2 tD + 3 1 - 3 t C@6D - 3 Cos@tD + 3 2 3 t Cos@tD + Sin@tD + 2 3 t Sin@tD + 2 3 t Sin@2 tD F>> 12
system . sol@@1DD . 8t RandomComplex@D, C@1D RandomComplex@D, C@2D RandomComplex@D, C@3D RandomComplex@D, C@4D RandomComplex@D, C@5D RandomComplex@D, C@6D RandomComplex@D< Chop
In general, systems of linear ODEs with non-constant coefficients can only be solved in cases where the coefficient matrix has a simple structure, as illustrated in the following examples.
This first-order system has a diagonal coefficient matrix. The system is uncoupled because the first equation involves only x@tD and the second equation depends only on y@tD. Thus, each equation in the system can be integrated independently of the other.
In[18]:=
The rows of the coefficient matrix for this system form an orthogonal set of vectors.
In[19]:= In[20]:=
46
In[21]:= In[22]:=
In[23]:=
Here is a system of three first-order ODEs. The coefficient matrix is upper triangular.
In[25]:= In[26]:=
Out[26]//MatrixForm=
In[27]:= In[28]:=
t Out[28]= 9x @tD x@tD + 2 y@tD + 3 z@tD, y @tD 2 y@tD - z@tD, z @tD z@tD=
In[29]:=
As for single ODEs, there are sophisticated modern algorithms for solving systems of ODEs with rational coefficients.
This solves a system of two first-order ODEs with rational coefficients. Note that the solution is composed entirely of rational functions.
In[30]:=
H5 + xL w@xD I- 3 - 2 x + x2 M I- 1 + x3 M -
I6 + 2 x - 3 x3 - x5 M y@xD + x I- 3 - 2 x + x2 M I- 1 + x3 M ,
I1 + 20 x2 + 3 x3 M w@xD H5 + xL I- 1 + x3 M
x C@1D -3 - 2 x + x2 +
x2 C@2D -3 - 2 x + x2
F, w FunctionB8x<,
F>>
In the following example, the algorithm finds one rational solution for x@tD and y@tD. (The equation for z@tD is uncoupled from the rest of the system.) Using the rational solution, DSolve is able to find the remaining exponential solution for x@tD and y@tD.
47
In the following example, the algorithm finds one rational solution for x@tD and y@tD. (The equation for z@tD is uncoupled from the rest of the system.) Using the rational solution, DSolve is able to find the remaining exponential solution for x@tD and y@tD.
In[31]:=
system = 8x '@tD H2 * HH- 9 + t + t ^ 2L * x@tD + H- 6 + t ^ 2L * y@tDLL HH- 2 + tL * tL, y '@tD H- 3 * H- 12 + 2 * t + t ^ 2L * x@tD + H24 - 2 * t - 3 * t ^ 2L * y@tDL HH- 2 + tL * tL, z '@tD t * z@tD<; sol = DSolve@system, 8x, y, z<, tD
H-2 - tL C@1D t3 H4 + tL C@1D t3 - 2 -t C@2DF,
t2
In[32]:=
y FunctionB8t<,
In[33]:=
The systems considered so far have all been homogeneous. If the system is inhomogeneous (that is, if there are terms free from any dependent variables and their derivatives), DSolve applies either the method of variation of parameters or the method of undetermined coefficients to find the general solution.
This solves an inhomogeneous system.
In[34]:= In[35]:= In[36]:= In[37]:=
A = 887, - 8<, 85, - 5<<; B = 8E ^ Ht 10L, t<; X@t_D = 8x@tD, y@tD<; system = MapThread@1 2 &, 8X '@tD, A.X@tD + B<D
48
In[38]:=
-4 t C@2D Sin@2 tD + t C@1D HCos@2 tD + 3 Sin@2 tDL - 4 t Sin@2 tD 1 50 t HCos@2 tD + 3 Sin@2 tDL 510 -t H18 + 70 tL Cos@2 tD + 225 481 -9 t10 Sin@2 tD 1 50
500 481
-9 t10 Cos@2 tD -
-t H-26 + 10 tL Sin@2 tD +
4 -9 t10 Cos@2 tD -t H4 + 10 tL Cos@2 tD + 481 25 470 2 -9 t10 Sin@2 tD -t H-6 + 10 tL Sin@2 tD F, 481 25 5 y FunctionB8t<, t C@2D HCos@2 tD - 3 Sin@2 tDL + t C@1D Sin@2 tD + 2 500 1 t HCos@2 tD - 3 Sin@2 tDL -9 t10 Cos@2 tD -t H18 + 70 tL Cos@2 tD + 481 50 225 1 5 510 -9 t10 Sin@2 tD -t H-26 + 10 tL Sin@2 tD + t Sin@2 tD -9 t10 Cos@2 tD 481 50 2 481 4 470 2 -t H4 + 10 tL Cos@2 tD + -9 t10 Sin@2 tD -t H-6 + 10 tL Sin@2 tD F>> 25 481 25
Particular solutions to the system can be obtained by assigning values to the constants C @1D and C @2D.
Here is a plot of the solution for one choice of parameters.
In[39]:= In[40]:=
particularsol = 8x@tD, y@tD< . sol@@1DD . 8C@1D - 1, C@2D 2<; Plot@Evaluate@particularsolD, 8t, 0, Pi<D
120 100 80
Out[40]=
49
In[2]:=
1+4 x C@3D
F C@3D + C@4DF>>
2
This system of two nonlinear ODEs is autonomous, in the sense that the right-hand sides of the equations do not depend on x.
In[4]:= In[5]:=
system = 8u '@xD 1 Sqrt@v@xDD, v '@xD u@xD<; sol = DSolve@system, 8u, v<, xD@@1DD
Out[5]= :v FunctionB8x<,
1 16
6 213 C@1D
13
-324 x +
6 213 C@1D
13
-324 x +
-324 x +
In[6]:=
The previous two examples demonstrate that the solutions to fairly simple systems are usually complicated expressions of the independent variable. In fact, the solution is often available only in implicit form and may thus contain InverseFunction objects or unevaluated Solve objects.
50
The previous two examples demonstrate that the solutions to fairly simple systems are usually complicated expressions of the independent variable. In fact, the solution is often available only in implicit form and may thus contain InverseFunction objects or unevaluated Solve objects.
For a fixed value of t, the point Hm, nL (in blue) can be obtained by rotating the line joining Hx, yL (in red) to the origin through an angle of t in the counterclockwise direction.
In[3]:=
Show@ 8Graphics@88Red, PointSize@0.04D, Point@83 * Cos@1 4D, 3 * Sin@1 4D<D<, 8Blue, PointSize@0.04D, Point@83 * Cos@H1 4L + HPi 3LD, 3 * Sin@H1 4L + HPi 3LD<D<, 8Green, Line@880, 0<, 83 * Cos@1 4D, 3 * Sin@1 4D<<D<, 8Green, Line@880, 0<, 83 * Cos@H1 4L + HPi 3LD, 3 * Sin@H1 4L + HPi 3LD<<D<<D, ParametricPlot@83 * Cos@tD, 3 * Sin@tD<, 8t, 0, 2 Pi<, DisplayFunction Identity D<, AspectRatio 1, ImageSize 200, Axes TrueD
3
Out[3]=
-3
-2
-1 -1 -2 -3
51
A rotation through t can be represented by the matrix Mt = cosHtL sinHtL . -sinHtL cosHtL
This shows that the set of all rotations in the plane satisfies the properties for forming a group.
In[3]:= In[4]:=
Out[4]= True
In[5]:=
Out[5]= True
In[6]:=
M@0D == IdentityMatrix@2D
Out[6]= True
In[7]:=
Out[7]= True
The Lie symmetry method requires calculating a first-order approximation to the expressions for the group. This approximation is called an infinitesimal generator.
This expands the expressions for m and n in a series with respect to t and around the origin 0 to obtain linear approximations.
In[8]:=
Out[8]= x + t y
In[9]:=
Out[9]= -t x + y
The coefficients of the linear terms in t are y and -x, respectively. The infinitesimal generator for the rotation group in the plane is defined to be the following differential operator.
In[10]:=
v = Hy * D@, xD - x * D@, yDL &; Starting from the infinitesimal generator, the original group can be recovered by integrating the fundamental system of Lie equations. For the group of rotations, the Lie equations are given by the first argument to DSolve shown here.
In[11]:=
Out[11]= 88x@tD C@1D Cos@tD + C@2D Sin@tD, y@tD C@2D Cos@tD - C@1D Sin@tD<<
The rotation group arises in the study of symmetries of geometrical objects; it is an example of a symmetry group. The infinitesimal generator, a differential operator, is a convenient local representation for this symmetric group, which is a set of matrices.
52
The rotation group arises in the study of symmetries of geometrical objects; it is an example of a symmetry group. The infinitesimal generator, a differential operator, is a convenient local representation for this symmetric group, which is a set of matrices. An expression that reduces to 0 under the action of the infinitesimal generator is called an invariant of the group.
Here is an invariant for this group.
In[12]:=
invariant = x ^ 2 + y ^ 2;
This states that the distance from the origin to Hx, yL,
In[13]:=
v@invariantD
Out[13]= 0
Riccatiequation = y '@xD + y@xD ^ 2 - 1 x ^ 2 0; The equation is invariant under the following scaling transformation.
In[15]:= In[16]:=
m = x * E ^ t; n = y * E ^ H- tL; The infinitesimal generator for this one-parameter group of transformations is found as before.
In[17]:=
Out[17]= x + t x
In[18]:=
Out[18]= y - t y
In[19]:=
Now, the Riccati equation depends on three variables: x, y = y@xD, and p = y @xD. Hence, the infinitesimal generator v must be prolonged to act on all three variables in this first-order equation.
It turns out that the required prolongation is as follows.
In[20]:=
53
This shows that the expression for the Riccati equation in the Hx, y, pL coordinates is indeed invariant under prolongedv.
In[21]:= In[22]:=
Out[22]= 0
Depending on the order of the given equation, the knowledge of a symmetry (in the form of an infinitesimal generator) can be used in three ways. If the order of the equation is 1, it gives an integrating factor for the ODE that makes the equation exact and hence solvable. It gives a set of canonical coordinates in which the equation has a simple (integrable) form. It reduces the problem of solving an ODE of order n to that of solving an ODE of order n - 1, which is typically a simpler problem. The DSolve function checks for certain standard types of symmetries in the given ODE and uses them to return a solution. Following are three examples of ODEs for which DSolve uses such a symmetry method.
Here is a nonlinear first-order ODE (equation 1.120, page 315 of [K59]).
In[23]:=
FirstOrderODE = x * y '@xD y@xD * Hx * Log@x ^ 2 y@xDD + 2L; This ODE has a symmetry with the following infinitesimal generator.
In[24]:=
v = H- 2 * Exp@- xD * yL * D@, yD &; The presence of this symmetry allows DSolve to calculate an integrating factor and return the solution.
In[25]:=
sol = DSolve@FirstOrderODE, y, xD
-x
C@1D
x2 E==
Out[26]= True
Here is a second-order nonlinear ODE, based on equation 6.93 on page 213 of [K59].
In[27]:=
54
m = x * E ^ t; n = y * E ^ t; The presence of this scaling symmetry allows DSolve to find new coordinates in which the independent variable is not explicitly present. Hence the problem is solved easily.
In[30]:=
sol = DSolve@SecondOrderODE, y, xD
Solve::ifun : Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.
1 6
x LogB6 -
C@1D x
- C@2D FF>>
Out[31]= 8True<
Finally, here is a system of two nonlinear first-order ODEs that can be solved by using a shift: u@xD u@xD - x. After the shift, the system becomes autonomous (it does not depend explicitly on x) and hence it can be solved by reduction to a first-order ODE for v as a function of u. The Solve::ifun message can be ignored; it is generated while inverting the expression for Exp@vD to give an expression in terms of Log.
In[32]:= In[33]:= In[34]:=
Clear@u, vD NonlinearSystem = 8u '@xD Exp@v@xDD + 1, v '@xD u@xD - x<; sol = DSolve@NonlinearSystem, 8u, v<, xD
Solve::ifun : Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.
2 x 2 x
C@1D + 2 C@1D + 2
2 2
u FunctionB8x<, x +
C@1D TanB
2 1 2
In[35]:=
In[36]:=
Clear@m, n, u, vD
55
equation1 =
! uHx, yL !x
+x
! uHx, yL !y
! sinHxL;
PDEs occur naturally in applications; they model the rate of change of a physical quantity with respect to both space variables and time variables. At this stage of development, DSolve typically only works with PDEs having two independent variables. The order of a PDE is the order of the highest derivative that occurs in it. The previous equation is a first-order PDE. A function uHx, yL is a solution to a given PDE if u and its derivatives satisfy the equation.
Here is one solution to the previous equation.
In[2]:=
equation1 . 8u sol<
Out[3]= True
Here are some well-known examples of PDEs (clicking a link in the table will bring up the relevant examples). DSolve gives symbolic solutions to equations of all these types, with certain restrictions, particularly for second-order PDEs.
56
name of equation
general form
!u !x !u !t
classification
transport equation Burgers equation eikonal equation Laplaces equation wave equation heat equation
+c +u
!u !y !u !x
! 0 with c constant !0
linear first-order PDE quasilinear first-order PDE nonlinear first-order PDE elliptic linear second-order PDE hyperbolic linear second-order PDE parabolic linear second-order PDE
J !x N + J !y N ! 1
!2 u !x
2
!u 2
!u 2
!2 u ! y2
!0
!2 u !t2
!2 u ! x2 !2 u ! x2
= c2 =k
!u !t
diffusivity
Recall that the general solutions to PDEs involve arbitrary functions rather than arbitrary constants. The reason for this can be seen from the following example.
The partial derivative with respect to y does not appear in this example, so an arbitrary function C @1D@yD can be added to the solution, since the partial derivative of C @1D@yD with respect to x is 0.
In[4]:=
If there are several arbitrary functions in the solution, they are labeled as C @1D, C @2D, and so on.
First-Order PDEs
Linear and Quasi-Linear PDEs
First-order PDEs are usually classified as linear, quasi-linear, or nonlinear. The first two types are discussed in this tutorial. A first-order PDE for an unknown function uHx, yL is said to be linear if it can be expressed in the form ! uHx, yL !x ! uHx, yL !y + cHx, yL uHx, yL ! d Hx, yL.
aHx, yL
+ bHx, yL
57
The PDE is said to be quasilinear if it can be expressed in the form ! uHx, yL !x ! uHx, yL !y ! cHx, y, uHx, yLL.
A PDE which is neither linear nor quasi-linear is said to nonlinear. For convenience, the symbols z, p, and q are used throughout this tutorial to denote the unknown function and its partial derivatives. ! uHx, yL !x ! uHx, yL !y
z = uHx, yL; p =
; q =
The equation is linear because the left-hand side is a linear polynomial in z, p, and q. Since there is no term free of z, p, or q, the PDE is also homogeneous.
As mentioned earlier, the general solution contains an arbitrary function C @1D of the argument
1 2
In[5]:=
H2 y - 3 xL.
Out[6]= True
Particular solutions of the homogeneous PDE are obtained by specifying the function C @1D.
In[7]:=
58
Out[8]=
The transport equation is a good example of a linear first-order homogeneous PDE with constant coefficients.
In this transport equation, c = 1 for convenience.
In[9]:=
Note that the solution to the transport equation is constant on any straight line of the form y ! x + a in the plane. These straight lines are called the base characteristic curves. The equation y ! x + a defines a plane in three dimensions. The intersections of these planes with the solution surface are called characteristic curves. Since the characteristic curves are solutions to a system of ODEs, the problem of solving the PDE is reduced to that of solving a system of ODEs for xHtL, yHtL, and uHtL, where t is a parameter along the characteristic curves. These ODEs are called characteristic ODEs. The solution to an inhomogeneous PDE has two components: the general solution to the homogeneous PDE and a particular solution to the inhomogeneous PDE.
This is a linear inhomogeneous PDE of the first order.
In[10]:=
eqn = 7 * p + 3 * q + z x + y;
59
The first part of the solution, -10 + x + y, is the particular solution to the inhomogeneous PDE. The rest of the solution is the general solution to the homogenous equation.
In[11]:=
Out[14]= True
eqn = p + x * q Cos@xD; The solution is once again composed of the general solution to the homogeneous PDE and a particular solution, Sin@ xD, to the inhomogeneous PDE.
In[16]:=
5 TanB
5 x+
5 C@1DB
1 2
I-x2 + 2 yMFFF>>
Out[19]= True
60
! uHx, yL !x
+ uHx, yL
! uHx, yL !y
!0
BurgersEquation = p + z q 0;
Out[24]= 0
A practical consequence of quasi-linearity is the appearance of shocks and steepening and breaking of solutions. Thus, although the procedures for finding general solutions to linear and quasi-linear PDEs are quite similar, there are sharp differences in the nature of the solutions.
Nonlinear PDEs
The general first-order nonlinear PDE for an unknown function uHx, yL is given by FHu, p, qL ! 0. Here F is a function of u = uHx, yL, p =
!uHx,yL !x
, and q =
!uHx,yL !y
The term nonlinear refers to the fact that F is a nonlinear function of p and q. For instance, the eikonal equation involves a quadratic expression in p and q. The general solution to a first-order linear or quasi-linear PDE involves an arbitrary function. If the PDE is nonlinear, a very useful solution is given by the complete integral. This is a function of uHx, y, C @1D, C @2DL, where C @1D and C @2D are independent parameters and u satisfies the PDE for all values of HC @1D, C @2DL in an open subset of the plane. The complete integral can be used to find a general solution for the PDE as well as to solve initial value problems for it.
61
The general solution to a first-order linear or quasi-linear PDE involves an arbitrary function. If the PDE is nonlinear, a very useful solution is given by the complete integral. This is a function of uHx, y, C @1D, C @2DL, where C @1D and C @2D are independent parameters and u satisfies the PDE for all values of HC @1D, C @2DL in an open subset of the plane. The complete integral can be used to find a general solution for the PDE as well as to solve initial value problems for it.
Here is a simple nonlinear PDE.
In[1]:= In[2]:= In[3]:= In[4]:=
z := u@x, yD p := D@u@x, yD, xD q := D@u@x, yD, yD eqn = p * q 1; The complete integral depends on the parameters C @1D and C @2D. Since DSolve returns a general solution for linear and quasi-linear PDEs, a warning message appears before a complete integral is returned.
In[5]:=
x C@2D
+ y C@2DF>>
eqn . sol
Out[6]= 8True<
If the values of C @1D and C @2D are fixed, the previous solution represents a plane in three dimensions. Thus, the complete integral for this PDE is a two-parameter family of planes, each of which is a solution surface for the equation. Next, the envelope of a one-parameter family of surfaces is a surface that touches each member of the family. If the complete integral is restricted to a one-parameter family of planes, for example by setting C @2D = 5 C @1D, the envelope of this family is also a solution to the PDE called a general integral.
62
This finds the envelope of the one-parameter family given by setting C @2D = 5 C @1D in the complete integral for the preceding PDE p * q == 1.
In[7]:=
Out[7]= u@x, yD
In[8]:=
2 Out[8]= 5 u@x, yD x H4 + 20 yL
In[10]:= Out[10]=
In[11]:=
Out[11]= 1
Like nonlinear ODEs, some nonlinear PDEs also have a singular solution (or singular integral) that is obtained by constructing the envelope of the entire two-parameter family of surfaces represented by the complete integral.
Here is an example of such a construction, (equation 6.4.13, page 429 of [K00]).
In[12]:=
F>>
In[13]:=
Out[13]= u@x, yD
In[14]:=
Out[14]= u@x, yD 1
Thus, the singular integral for this PDE is a plane parallel to the x-y plane.
63
Thus, the singular integral for this PDE is a plane parallel to the x-y plane. To summarize, the complete integral for a nonlinear PDE includes a rich variety of solutions. Every member of the two-parameter family gives a particular solution to the PDE. The envelope of any one-parameter family is a solution called a general integral of the PDE. The envelope of the entire two-parameter family is a solution called the singular integral of the PDE. The complete integral is not unique, but any other complete integral for the PDE can be obtained from it by the process of envelope formation. These remarkable properties account for the usefulness of the complete integral in geometrical optics, dynamics, and other areas of application. Following are various examples of nonlinear PDEs that show different kinds of complete integrals.
Here is the complete integral for the eikonal equation.
In[15]:= In[16]:=
This complete integral is a two-parameter family of planes. This type of solution arises whenever the PDE depends explicitly only on p and q, but not on u@x, yD, x, or y. For a fixed value of u@x, yD, it is a line in the plane at a distance of C @1D units from the origin that makes an angle of ArcCos@C @2DD with the x axis. This is the familiar picture of wave-front propagation from geometrical optics.
This verifies the solution for the eikonal equation.
In[17]:=
Eikonal . sol
64
1 - C@1D2 C@2DF>>
Clairaut . sol
Out[20]= 8True<
In the following equation, the variables can be separated; that is, the PDE can be written in the form f Hx, pL ! gHy, qL. Hence, the equation can be integrated easily.
In[21]:= In[22]:=
3 y2 2a 3 y2 2a
2 3 2 3
Hx - C@1DL32 + Hx - C@1DL32 +
y C@1D a y C@1D a
+ C@2DF>, + C@2DF>>
:u FunctionB8x, y<,
In this example (equation 6.49, page 202 of [K74]), the independent variables x and y are not explicitly present.
In[24]:= In[25]:=
c x CA1E CA1E2
c CA2E
-b CA1E-a
-b CA1E-a
-b CA1E-a CA1E2
F>>
65
Out[26]= 8True<
Often a coordinate transformation can be used to cast a given PDE into one of the previous types. The expression for the complete integral will then have the same form as for the standard types. Here are some examples of nonlinear PDEs for which DSolve applies a coordinate transformation to find the complete integral.
This PDE (equation 6.47, page 201 of [K74]) can be reduced to the form f H p, qL ! 0 using the transformation X = logHxL and Y = logHyL.
In[27]:=
Log@yD C@1D
>>
This PDE (equation 6.93, page 213 of [K74]) can be solved easily in a polar coordinate system, in which the variables are separable.
In[28]:=
This equation (equation 6.36, page 196 of [K74]) can be transformed into a linear PDE using a Legendre transformation.
In[29]:= In[30]:=
1 4 C@1D
F>, :u
FunctionB8x, y<,
-y H-2 x + 2 C@2DL +
F>>
66
It should be noted that there is no general practical algorithm for finding complete integrals, and that the answers are often available only in implicit form.
The solution to this example (problem 2, page 66 of [S57]) is in implicit form.
In[32]:=
Out[32]= SolveB
1 2
C@1D LogB-C@1D +
Out[33]=
2 x u@x, yD
In[34]:=
Out[34]=
In[35]:=
H1 + q ^ 2L * z - p * x Simplify
Out[35]= 0
Second-Order PDEs
The general form of a linear second-order PDE is !2 u ! x2 !2 u !x!y !2 u ! y2 !u !x !u !y
+b
+ c
+ d
+e
+ f u ! g.
Here u = uHx, yL, and a, b, c, d , e, f , and g are functions of x and y only~they do not depend on u. If g = 0, the equation is said to be homogeneous.
67
Here u = uHx, yL, and a, b, c, d , e, f , and g are functions of x and y only~they do not depend on u. If g = 0, the equation is said to be homogeneous. The first three terms containing the second derivatives are called the principal part of the PDE. They determine the nature of the general solution to the equation. In fact, the coefficients of the principal part can be used to classify the PDE as follows. The PDE is said to be elliptic if b2 - 4 a c < 0. The Laplace equation has a = 1, b = 0, and c = 1 and is therefore an elliptic PDE. The PDE is said to be hyperbolic if b2 - 4 a c > 0. The wave equation has a = 1, b = 0, and c = -1 and is therefore a hyperbolic PDE. The PDE is said to be parabolic if b2 - 4 a c = 0. The heat equation has a = 1, b = 0, and c = 0 and is therefore a parabolic PDE. DSolve can find the general solution for a restricted type of homogeneous linear second-order PDEs; namely, equations of the form !2 u ! x2 !2 u !x!y !2 u ! y2
+b
+c
= 0.
Here a, b, and c are constants. Thus, DSolve assumes that the equation has constant coefficients and a vanishing non-principal part. Following are some examples of the three basic types (elliptic, hyperbolic, and parabolic) and an explanation of their significance.
Here is the general solution for Laplaces equation, an elliptic PDE.
In[1]:= In[2]:=
LaplaceEquation = D@u@x, yD, 8x, 2<D + D@u@x, yD, 8y, 2<D 0; DSolve@LaplaceEquation, u@x, yD, 8x, y<D
This general solution contains two arbitrary functions, C @1D and C @2D. The arguments of these functions, y + x and y - x, indicate that the solution is constant along the imaginary straight line y = - x + a when C @2D 0 and along y = x + a when C @1D 0 . These straight lines are called characteristic curves of the PDE. In general, elliptic PDEs have imaginary characteristic curves.
68
a = 3; b = 1; c = 5; b ^ 2 - 4 a * c
Out[3]= -59
In[4]:=
eqn = a * D@u@x, yD, 8x, 2<D + b * D@u@x, yD, x, yD + c * D@u@x, yD, 8y, 2<D 0; Note the imaginary characteristic curves for the equation.
In[5]:=
Out[6]= 8True<
This finds the general solution of the wave equation, a hyperbolic PDE. The constant c in the wave equation represents the speed of light and is set to 1 here for convenience.
In[7]:= In[8]:=
WaveEquation = D@u@x, tD, 8x, 2<D - D@u@x, tD, 8t, 2<D 0; DSolve@WaveEquation , u@x, tD, 8t, x<D
The characteristic lines for the wave equation are x = k + t and x = k - t where k is an arbitrary constant. Hence the wave equation (or any hyperbolic PDE) has two families of real characteristic curves. If initial conditions are specified for the wave equation, the solution propagates along the characteristic lines. Also, any fixed pair of characteristic lines determine the null cone of an observer sitting at their intersection.
Here is another example of a hyperbolic PDE.
In[9]:=
a = 2; b = 7; c = - 1; b ^ 2 - 4 a * c
Out[9]= 57
In[10]:=
eqn = a * D@u@x, yD, 8x, 2<D + b * D@u@x, yD, x, yD + c * D@u@x, yD, 8y, 2<D 0; Notice that the equation has two families of real characteristics.
In[11]:=
69
Out[12]= 8True<
a = 3; b = 30; c = 75; b ^ 2 - 4 a * c
Out[13]= 0
In[14]:= In[15]:=
eqn = a * D@u@x, yD, 8x, 2<D + b * D@u@x, yD, x, yD + c * D@u@x, yD, 8y, 2<D 0; sol = DSolve@eqn, u, 8x, y<D
The equation has only one family of real characteristics, the lines y = 5 x + a. In fact, any parabolic PDE has only a single family of real characteristics.
The solution can be verified as follows.
In[16]:=
Out[16]= 8True<
The heat equation is parabolic, but it is not considered here because it has a nonvanishing nonprincipal part, and the algorithm used by DSolve is not applicable in this case.
70
These tutorials are restricted to linear DAEs, which are defined as systems of equations of the following type. A.x HtL + B.xHtL ! F Here A and B are matrix functions of the independent variable t, F is a vector function of t, and xHtL is the vector of unknowns. If the matrix A is nonsingular (that is, invertible) then this is a system of ODEs. Thus, the system is a DAE if the matrix A is singular. If F ! 0, then the system is said to be homogeneous. As for ODEs, the general solution to a DAE is composed of the general solution to the corresponding homogeneous problem and a particular solution to the inhomogeneous system. DSolve can find the solutions to all DAEs in which the entries of the matrices A and B are constants. Such DAEs are said to have constant coefficients. The algorithm used by DSolve is based on decomposing both A and B into a nonsingular and nilpotent part. This decomposition is used to calculate a generalized inverse for A and B, which effectively reduces the problem to solving a system of ODEs. It is important to realize that the initial values for a DAE must be prescribed carefully to guarantee a solution for the problem. This can be seen by considering the following system of equations.
71
It is important to realize that the initial values for a DAE must be prescribed carefully to guarantee a solution for the problem. This can be seen by considering the following system of equations. 8x1 HtL + x2 HtL ! 0, x2 HtL ! 0, x1 H0L ! 1, x2 H0L ! 0< This gives x2 HtL ! 0 x2 HtL ! 0 x1 HtL ! 0. Hence the only solution is x1 HtL ! 0 and x2 HtL ! 0. But this solution is inconsistent with the initial condition x1 H0L ! 1. DSolve can solve DAEs with constant coefficients; see "Examples of DAEs".
Examples of DAEs
This is a simple homogeneous DAE with constant coefficients.
In[1]:=
eqns =
This finds the general solution. It has only one arbitrary constant because the second equation in the system specifies the relationship between x@tD and y@tD.
In[2]:=
72
The general solution is composed of the general solution to the corresponding homogeneous system and a particular solution to the inhomogeneous equation.
In[5]:=
Out[5]= :1 +
eqns = 8x '@tD - y@tD Sin@tD, x@tD + y@tD == 1, x@PiD == 1 2<; sol = DSolve@eqns, 8x, y<, tD
-t I2 p - 2 t + t Cos@tD - t Sin@tDMF, 2 1 -t I2 p + t Cos@tD - t Sin@tDMF>> y FunctionB8t<, 2 1
1.0
Out[8]=
0.5
-0.5
Clear@x, y, z, f, g, h, tD eqns = 8x@tD + y '@tD f@tD, 2 y@tD + z '@tD g@tD, 5 z@tD h@tD<; Note that there are no degrees of freedom in the solution (that is, there are no arbitrary constants) because z@tD is given algebraically, and thus x@tD and y@tD can be determined uniquely from z@tD using differentiation.
In[11]:=
In[12]:=
In this example, the algebraic constraint is present only implicitly: all three equations contain derivatives of the unknown functions.
73
In this example, the algebraic constraint is present only implicitly: all three equations contain derivatives of the unknown functions.
In[13]:= In[14]:=
Clear@x1, x2, x3, t, eqnsD eqns = 8x2@tD + 2 x3@tD + x1 @tD - 2 x3 @tD == 0, - 27 x1@tD - 22 x2@tD - 17 x3@tD - x1 @tD + 2 x3 @tD == 0, 18 x1@tD + 14 x2@tD + 10 x3@tD + 2 x1 @tD + 3 x2 @tD + 2 x3 @tD == 0<; The Jacobian with respect to the derivatives of the unknown functions is singular, so that it is not possible to solve for them.
In[15]:=
In[16]:=
Det@AD
Out[16]= 0
The differential-algebraic character of this problem is clear from the smaller number of arbitrary constants (two rather than three) in the general solution.
In[17]:=
Systems of equations with higher-order derivatives are solved by reducing them to first-order systems.
Here is the general solution to a homogeneous DAE of order two with constant coefficients.
In[18]:= In[19]:=
eqns = 8x ''@tD == y@tD, x@tD + 4 y@tD == 0<; sol = DSolve@eqns, 8x, y<, tD
t 1 t 16 t t C@2D CosB F C@1D CosB F + 2 C@2D SinB F F, C@1D SinB F + 125 2 2 2 125 2 2 44 t 1 t 4 t t C@2D CosB F C@1D CosB F + 2 C@2D SinB F F>> C@1D SinB F y FunctionB8t<, 125 2 2 2 125 2 2 176
In[20]:=
74
In[22]:=
In[23]:=
eqns = 8x ''@tD == y@tD, x@tD + 4 y@tD == Sin@tD, x@PiD == 1, x '@PiD == 0<; sol = DSolve@eqns, 8x, y<, tD
t t 2 CosB F + 3 SinB F - Sin@tD F, 3 2 2 1 t t -2 CosB F - 3 SinB F + 4 Sin@tD F>> y FunctionB8t<, 12 2 2 1
0.5
-6
-4
-2
Out[26]=
-0.5
-1.0
-1.5
Finally, here is a system with a third-order ODE. Since the coefficients are exact quantities, the computation takes some time.
In[27]:= In[28]:=
Clear @p, q, rD eqns = 8p '''@tD - q@tD + r@tD - Sin@tD, p ''@tD - r@tD - Cos@tD, p '@tD - q@tD + 4, p@0D - 1, p '@0D - 1, p ''@0D - 1<;
75
In[29]:=
Out[29]= :9.156,
1 5 N J1 +
t
4 -410 - 17 2 5 N
+
1 2 5 t 2
-1-
+9
5 2
-1-
- 17 2
-1+
5 2
t
-1+
1 2
+ 440 2
t
-1-
+ 20 t - 34 Cos@tD +
t
33 2
5 t 2
-1-
5 t 2
1 2
-1-
Sin@tD F,
t
1
q FunctionB8t<,
t
1 5
20 + 14 2
5 t
t
-1-
-4
5
5 2
t
-1-
+ 14 2
5 t 2
-1+
+4
5 2
-1+
20 2
5 t 2
1 2
-1-
- 3 2
-15
5 t 2
1 2
-1-
Cos@tD - 2
5 t
1 2
-1-
Sin@tD F,
1
r FunctionB8t<,
t
1 5
3 2
5 t 2
-5
5 2
-1-
+ 3 2
-15
-1+
+5
5 2
-1+
5 Cos@tD - 2
1 2
-1-
Cos@tD + 3 2
5 t 2
1 2
Sin@tD F>>>
In[30]:=
The symbolic solution of DAEs that are nonlinear or have non-constant coefficients is a difficult problem. Such systems can often be solved numerically with the Mathematica function NDSolve .
76
77
linearequation = y '@tD - 3 * t * y@tD 1; Notice that the general solution is a linear function of the arbitrary constant C @1D.
In[2]:=
Out[2]= ::y@tD
C@1D +
p 6
ErfB
3 2
tF>>
24 +
6 p ErfB
3 2
tF F>>
This verifies that the solution satisfies both the equation and the initial condition.
In[4]:=
linearequation . particularsolution@@1DD
Out[4]= True
In[5]:=
y@0D . particularsolution@@1DD
Out[5]= 4
Here is the solution to the same problem with the general initial condition y@0D == a.
In[6]:=
6a+
6 p ErfB
3 2
tF F>>
78
This plots several integral curves of the equation for different values of a. The plot shows that the solutions have an inflection point if the parameter a lies between -1 and 1, while a global maximum or minimum arises for other values of a.
In[7]:=
Out[7]=
-1.5
-1.0
-0.5
0.5
1.0
1.5
-2
-4
Here is the solution to a linear second-order equation with initial values prescribed for x@tD and x @tD at t == 0.
In[8]:= In[9]:=
In[10]:=
This verifies that the solution satisfies the equation and the initial conditions.
In[11]:=
Out[11]= True
In[12]:=
x@0D . particularsolution@@1DD
Out[12]= 1
In[13]:=
x '@0D . particularsolution@@1DD
Out[13]= 1
79
Out[14]=
0.5 -0.2
1.0
1.5
2.0
To get more information about the solutions for the problem, set x @0D == x0.
In[15]:=
Here is a plot of the solutions for different initial directions. The solution approaches - or as t - according to whether the value of x0 is less than or greater than -2, which is the largest root of the auxiliary equation for the ODE.
In[16]:=
Show@GraphicsArray@Partition@ Table@Plot@Evaluate@x@tD . particularsolution@@1DD . x0 iD, 8t, - 1, 3<, PlotStyle 8Red<, PlotLabel StringJoin@"x0= ", ToString@iDD, Ticks NoneD, 8i, - 4, 1<D, 83<D, ImageSize 400DD
x0= -4 x0= -3 x0= -2
Out[16]=
x0= -1
x0= 0
x0= 1
80
In[19]:=
It should be noted that, in contrast to initial value problems, there are no general existence or uniqueness theorems when boundary values are prescribed, and there may be no solution in some cases.
This problem has no solution because the term with C @2D in the general solution vanishes at both x ! 0 and x ! p. Hence there are two inconsistent conditions for the parameter C @1D and the solution is an empty set.
In[20]:=
Out[20]= 8<
The previous discussion of linear equations generalizes to the case of higher-order linear ODEs and linear systems of ODEs.
Here is the solution to an Initial Value Problem (IVP) for a linear ODE of order four.
In[21]:= In[22]:=
fourthorderODE = y ''''@xD + 2 * y ''@xD + y@xD Cos@xD; sol = DSolve@8fourthorderODE, y@0D 1, y '@0D 6, y ''@0D 3, y '''@0D - 1<, y, xD
I11 Cos@xD - 40 x Cos@xD - 2 x2 Cos@xD + 16 4 Cos@xD3 + Cos@xD Cos@2 xD + 136 Sin@xD + 34 x Sin@xD + 3 Sin@xD Sin@2 xDMF>> 1
Since this is a fourth-order ODE, four independent conditions must be specified to find a particular solution for an IVP. If there is an insufficient number of conditions, the solution returned by DSolve may contain some of the arbitrary parameters, as follows.
In[24]:=
81
Clear@x, y, z, tD linearsystem = 8x '@tD x@tD - 4 * y@tD + 1, y '@tD 4 * x@tD + y@tD, z '@tD z@tD<; initialvalues = 8x@0D 2, y@0D - 1, z@0D 1<; sol = DSolve@Join@linearsystem, initialvaluesD, 8x, y, z<, tD
1 17 1 I35 t Cos@4 tD - Cos@4 tD2 + 21 t Sin@4 tD - Sin@4 tD2 MF,
I-21 t Cos@4 tD + 4 Cos@4 tD2 + 35 t Sin@4 tD + 4 Sin@4 tD2 MF, 17 z FunctionA8t<, t E>> y FunctionB8t<,
This verifies that the solution satisfies the system and the initial conditions.
In[29]:=
The solutions x@tD, y@tD, and z@tD are parametrized by the variable t and can be plotted separately in the plane or as a curve in space.
In[30]:=
Out[30]=
-2.0 -1.5 -1.0 -0.5 0.5 1.0
-2
-4
82
In[31]:=
0.04
Out[31]= 0.02
0.00 0.10 0.05 0.00 0.05 0.15 0.20 0.25
LogisticEquation = y '@tD r H1 - Hy@tD KLL * y@tD; The right-hand side of the equation can be expanded to a quadratic polynomial in y@tD. Hence, the logistic equation is simply a Riccati equation, and its general solution can be easily found.
In[2]:=
DSolve@LogisticEquation, y, tD
r t+K C@1D K -1 + r t+K C@1D F>>
This sets the intrinsic growth rate r to 1 2 and the saturation level K to 4 and solves the initial value problem. The warning message from Solve is issued while solving for the arbitrary constant C @1D from the general solution.
In[3]:=
4 t2 3 + t2
F>>
83
This solves the initial value problem for the logistic equation with symbolic parameters r and K.
In[4]:=
a r t K 1 - a + a r t
F>>
This verifies that the solution satisfies the equation and the initial condition.
In[5]:=
Plot@Evaluate@Table@y@tD . sol@@1DD . 8K 4, a i, r H1 3L<, 8i, 2, 1 10, - 1 3<DD, 8t, 0, 8<, PlotRange AllD
8 7 6 5 4 3
Out[6]=
Here is an example of an IVP for a second-order nonlinear ODE whose general solution can be obtained in explicit form.
In[7]:= In[8]:=
eqn = y ''@xD - H1 2L * Hy '@xD ^ 2 y@xDL + 1 H2 * y@xDL 0; sol = DSolve@8eqn, y@0D 1, y '@0D 2<, y, xD
1 4 I4 + 8 x + 3 x2 MF>>
This verifies that the solution satisfies the equation and the initial conditions.
In[9]:=
Finally, here is a boundary value problem for a nonlinear second-order ODE. The solution is required to satisfy boundary conditions at 0 and infinity. The Solve::ifun message is generated while finding the general solution in terms of JacobiSN , the inverse of EllipticF. The DSolve::bvlim messages are given because the limit required for satisfying the condition y @Infinity D 0 cannot be calculated for either branch of the general solution. However, the solution for the boundary value problem is found using an alternative method to determine the
84
Finally, here is a boundary value problem for a nonlinear second-order ODE. The solution is required to satisfy boundary conditions at 0 and infinity. The Solve::ifun message is generated while finding the general solution in terms of JacobiSN , the inverse of EllipticF. The DSolve::bvlim messages are given because the limit required for satisfying the condition y @Infinity D 0 cannot be calculated for either branch of the general solution. However, the solution for the boundary value problem is found using an alternative method to determine the values of the constants C @1D and C @2D in the general solution.
In[10]:=
Out[10]= ::y@xD
1 - C@1D 1 - C@1D
F-
1 - C@1D
JacobiSNB 11+
x2 + x2
1 - C@1D + 2 x C@2D + 2 x 1 1-
1 - C@1D 1 - C@1D
F>, :y@xD -
JacobiSNB 11+
x2 + x2
1 - C@1D 1 - C@1D
F+
1 - C@1D JacobiSNB
x2 + x2
1 - C@1D + 2 x C@2D + 2 x
1 - C@1D C@2D2 ,
11+
1 - C@1D 1 - C@1D
F>>
In[11]:=
x2 F>>
85
In[12]:=
Out[12]=
0.4 0.2 -2 -1 1 2
It may not always be possible to obtain a symbolic solution to an IVP or BVP for a nonlinear equation. Numerical methods may be necessary in such cases.
Out[1]=
1 + x2 True
86
The solution can be plotted in the usual way. Note that the solution is continuous but not differentiable at x = 0.
In[5]:=
Out[5]=
-3
-2
-1
Out[7]= ::y@xD
x1 >> True
In[8]:=
15
Out[8]=
10
-3
-2
-1
A piecewise ODE can be thought of as a collection of ODEs over disjoint intervals such that the expressions for the coefficients and the boundary conditions change from one interval to another. Thus, different intervals have different solutions, and the final solution for the ODE is obtained by patching together the solutions over the different intervals.
For this piecewise ODE, the expression for FinalSol is obtained by patching together SolFromMinusInfinityToTwo and SolFromTwoToInfinity. The boundary condition for the interval H- Infinity, 2D is simply y@0D = 1, while the initial condition for the interval @2, Infinity L is y@2D ! 2 (given by the final value for the solution over the first interval).
87
For this piecewise ODE, the expression for FinalSol is obtained by patching together SolFromMinusInfinityToTwo and SolFromTwoToInfinity. The boundary condition for the interval H- Infinity, 2D is simply y@0D = 1, while the initial condition for the interval @2, Infinity L is y@2D ! 2 (given by the final value for the solution over the first interval).
In[9]:=
t2 True
F>>
In[10]:=
In[11]:=
F>>
If there are a large number of discontinuities in a problem, it is convenient to use Piecewise directly in the formulation of the problem.
This second-order ODE contains a Piecewise term.
In[12]:= In[13]:=
eqn = 8y ''@tD + y@tD Piecewise@88- 1, t < 0<, 81, t < 1<, 8Sin@tD, t < 2<<D, y@0D 1, y '@0D 1<; sol = DSolve@ eqn, y, t D
t 0< 1<
2 2
I4 Cos@1D Cos@tD + 2 Cos@1D Cos@tD - 2 t Cos@1D Cos@tD - 2 Cos@1D Cos@tD Sin@1D + 2 Cos@tD Sin@1D2 - 2 t Cos@tD Sin@1D2 + 6 Cos@1D2 Sin@tD - 2 Cos@1D2 Cos@tD2 Sin@tD + 4 Sin@1D Sin@tD + 4 Sin@1D2 Sin@tD - 2 Cos@tD2 Sin@1D2 Sin@tD + Cos@1D2 Cos@tD Sin@2 tD + Cos@tD Sin@1D2 Sin@2 tDM
1 4 ICos@2D2 +Sin@2D2 M
True
2
I4 Cos@1D Cos@2D Cos@tD - 2 Cos@2D Cos@tD - Cos@tD Sin@2D + 2 Cos@2D Cos@tD Sin@2D + 4 Cos@tD Sin@1D Sin@2D - 2 Cos@tD Sin@2D2 + Cos@2D Sin@tD + 3 Cos@2D2 Sin@tD 4 Cos@2D Sin@1D Sin@tD + 4 Cos@1D Sin@2D Sin@tD + 5 Sin@2D2 Sin@tDM F>>
This ODE contains the Clip function. The solutions are given in terms of Airy functions.
In[14]:=
88
In[15]:=
DSolve@eqn, y, xD
x
56 3 1 3
J3 3
13
33
13
Cos@xD GammaB F Sin@1D + 3 313 AiryAiPrime@-1D Cos@1D GammaB F Sin@xD 356 AiryBiPrime@-1D Cos@1D GammaB F Sin@xD - 3 313 AiryAi@-1D GammaB F Sin@1D Sin@xD +
3 3 1 1
-1 < True
-1-x 2
J-3 AiryAi@1D - 3
2x
2x
AiryAiPrime@1D +
3 2 AiryBiPrime@1D +
89
90
Out[1]= ::y@xD
The output of DSolve is a list of solutions for the differential equation. The extra list is required since some equations have multiple solutions. Here, since the equation is of order 1 and is linear, there is only one solution: y@xD
1 5
constant C @1D because no initial condition was specified. The solution can be extracted from the list of solutions using a part specification.
This extracts the solution.
In[2]:=
m = sol@@1DD
1 5 + -5 x C@1D>
Out[2]= :y@xD
This form of the solution is useful for finding y@xD itself, but not for finding derivatives of y@xD or the value of y@xD at a point.
This shows the value of y@xD given by the solution.
In[3]:= Out[3]=
y@xD . m
1 5 + -5 x C@1D
The solution does not apply to y @ xD or y@1D because the solution is a rule for y@xD only.
In[4]:=
y '@xD . m
Out[4]= y @xD
In[5]:=
y@1D . m
Out[5]= y@1D
If the solution will be used in further work, it is best to specify the unknown function using y rather than y@xD. This gives the solution using pure functions of the type Function @x, exprD.
91
If the solution will be used in further work, it is best to specify the unknown function using y rather than y@xD. This gives the solution using pure functions of the type Function @x, exprD.
Here, the unknown function is specified as y. The solution is a pure function.
In[6]:=
When the solution is in the form of pure functions, expressions can be found for derivatives of y and for the values of y at specific points.
This gives expressions for y@xD, y @ xD, and y@1D.
In[7]:=
m = sol@@1DD
1 5 + -5 x C@1DF>
Out[7]= :y FunctionB8x<,
In[8]:= Out[8]=
y@xD . m
1 5 + -5 x C@1D
In[9]:=
y '@xD . m
-5 x C@1D Out[9]= -5
In[10]:= Out[10]=
y@1D . m
1 5 + C@1D 5
When a problem has multiple solutions, you can pick out individual solutions from the solution list or you can work directly with the list.
This solves a nonlinear first-order equation. There are two solutions.
In[11]:=
y@xD . sol@@1DD
2 3 H11 + xL32 + C@1D
Out[12]= -
92
In[13]:= Out[13]=
y@xD . sol@@2DD
2 3 H11 + xL32 + C@1D
y@xD . sol
2 3 H11 + xL32 + C@1D, 2 3 H11 + xL32 + C@1D>
Out[14]= :-
To solve a system of equations, the first argument to DSolve must be a list of the equations and the second argument must be a list of the unknown functions.
Here is an example of a system of first-order linear equations with three unknowns. Because this system is linear, there is only one solution.
In[15]:=
sol = DSolve@ 8x '@tD y@tD + z@tD, y '@tD + z@tD - x@tD 0, z '@tD + y@tD x@tD<, 8x, y, z<, tD
1 3 1 3 1 3 -2 t I1 + 2 3 t M C@1D + -2 t I-1 + 3 t M C@1D + -2 t I-1 + 3 t M C@1D 1 3 1 3 1 3 -2 t I-1 + 3 t M C@2D + -2 t I1 + 2 3 t M C@2D -2 t I-1 + 3 t M C@2D + 1 3 1 3 1 3 -2 t I-1 + 3 t M C@3DF, -2 t I-1 + 3 t M C@3DF, -2 t I1 + 2 3 t M C@3DF>>
y FunctionB8t<, z FunctionB8t<,
Each solution to the system is a list of replacement rules for the unknown functions. The expressions for the unknown functions can be extracted as in previous examples.
This gives a list of the expressions for the unknown functions. Simplify is used to return the expressions in a compact form.
In[16]:=
Out[16]= :
If initial conditions are prescribed for the problem, some or all of the undetermined constants can be eliminated.
Here the value of the unknown function and its derivative are both prescribed at the initial point.
In[17]:=
If only the initial value is specified, then the solution still contains an arbitrary constant.
93
If only the initial value is specified, then the solution still contains an arbitrary constant.
In[18]:=
For a partial differential equation, the third argument to DSolve is a list of the independent variables for the equation.
This solves a PDE with independent variables x and y. C @1D represents an arbitrary function of y + Cos@y@xDD.
In[19]:=
A differential-algebraic equation is specified in the same way as a system of ordinary differential equations.
Here is an example of a DAE with an initial condition.
In[20]:=
DSolve@8x '@tD + y@tD Sin@tD, x@tD + y@tD 1, x@0D 4<, 8x, y<, tD
1 2 I2 + 7 t - Cos@tD - Sin@tDMF, y FunctionB8t<, 1 2 I-7 t + Cos@tD + Sin@tDMF>>
Note that it is not always possible to give the solutions for a problem in explicit form. In this case, the solution is given using an unevaluated Solve object or using InverseFunction .
The solution to this equation is not available explicitly. The output represents an implicit solution.
In[21]:=
Log@-1 + y@xDD 2 1 + 3 12
sol@@1DD
Log@-1 + y@xDD 2 1 + 3 12 &F -x + C@1D
94
InverseFunctionBC@1D LogB1 +
-2 C@1D + 12 F -
1 2
-2 C@1D + 12 F +
Each solution can be rewritten as an implicit equation by eliminating the InverseFunction object as follows.
In[24]:=
In[25]:=
In[3]:=
eqn . sol
Out[3]= 8True<
95
In this example, the equation and an initial condition are verified by substitution.
In[4]:= In[5]:=
In[6]:=
eqn . sol
Sometimes the result of the substitution is more complicated than True or False . Such examples can be verified by using Simplify to simplify the result of the substitution. If the simplified result is True , the solution is valid.
Here is the general solution for a second-order inhomogeneous equation.
In[7]:= In[8]:=
eqn . sol
1 6 + -3 x C@1D + -2 x C@2D 1>
Simplify@eqn . solD
Out[10]= 8True<
PDE = D@u@x, yD, xD + Sin@xD * D@u@x, yD, yD x ^ 2; sol = DSolve@PDE, u, 8x, y<D
1 3 Ix3 + 3 C@1D@y + Cos@xDDMF>>
In[13]:=
Simplify@PDE . solD
Out[13]= 8True<
If the equation involves special functions, it may be necessary to use FullSimplify to verify the solution.
96
If the equation involves special functions, it may be necessary to use FullSimplify to verify the solution.
Here is an example of this type involving Bessels functions.
In[14]:= In[15]:=
In[16]:=
FullSimplify@eqn . solD
Out[16]= 8True<
If the solution is large or if Simplify and FullSimplify do not succeed in verifying the solution, a numerical check can be made by using RandomReal or RandomComplex to generate values for all the variables and parameters in the problem. It is advisable in such cases to repeat the check with several sets of random values.
Here is an example where numerical verification is useful.
In[17]:= In[18]:= In[19]:=
238
Out[19]= ::y FunctionB8x<,
Ix4 M
38
-1+3 8 a
3 4
, -
1 2
a x4 F +
a x4
238
Ix4 M
38
C@2D LaguerreLBx32
-1+3 8 a
, - , 4
1 2
a x4 F F>>
In[20]:=
Union@Flatten@Table@Chop@eqn . sol . 8x RandomReal@D, a RandomReal@D, C@1D RandomReal@D, C@2D RandomReal@D<D, 8i, 1, 10<DDD
Out[20]= 80<
Although numerical checks cannot verify a solution with certainty, more rigorous checks can be made by using higher precision or by allowing the variables to take complex values.
This verifies the previous solution with higher precision.
In[21]:=
Chop@eqn . sol . 8x RandomReal@ 81, 2<, WorkingPrecision -> 20D, a RandomReal@ 81, 2<, WorkingPrecision -> 20D, C@1D RandomReal@ 81, 2<, WorkingPrecision -> 20D , C@2D RandomReal@ 81, 2<, WorkingPrecision -> 20D<D
Out[21]= 80<
97
Out[23]= 80<
The previous methods are of use only when the solution is available in explicit form. The final example shows how to verify the solution of a first-order ODE when it is given in implicit form.
This solves a first-order ODE.
In[24]:= In[25]:=
F + AiryAiPrimeBx2 F + AiryBiPrimeBx2 -
1 y@xD 1 y@xD
F + C@1D 0, y@xDF F
Out[25]= SolveB
-x AiryBiBx2 In[26]:=
sol@@1DD
-x AiryAiBx2 1 y@xD 1 y@xD
F + AiryAiPrimeBx2 F + AiryBiPrimeBx2 -
1 y@xD 1 y@xD
F + C@1D 0 F
Out[26]=
-x AiryBiBx2 -
98
C@1D +
1 2
x2 2
p 10
1 + 2 ErfiB
1 2
- xF +
1 - 2 ErfiB
1 2
+ xF F>>
The solution can be plotted for specific values of the constant C @1D using Plot . The use of Evaluate reduces the time taken by Plot and can also help in cases where the solution has discontinuities.
In[2]:=
1.0
Out[2]=
0.5
-6
-4
-2
Here is the plot for a linear second-order ODE with initial values prescribed at 0.
In[3]:=
10
15
20
25
30
Out[4]= -2
-4 -6
This nonlinear equation has two solutions that can be plotted on the same graph.
99
This nonlinear equation has two solutions that can be plotted on the same graph.
In[5]:=
1 - x2 + 2 x32
1 - x2
-x I-1 + x2 M +
:y FunctionB8x<,
1 - x2 - 2 x32
1 - x2
-x I-1 + x2 M -
In[6]:=
1.2
Out[6]= 1.0
0.8
0.2
0.4
0.6
0.8
y@xD3 x
, y@xD, xF
Solve::tdep : The equations appear to involve the variables to be solved for in an essentially non-algebraic way.
1
Out[7]= SolveB-5 x
2 2 2 C@1D +
K-5 x+
1 y@xD
, y@xDF
-5 x+
1 y@xD
2 p ErfiB
A contour plot can be used to study the nature of the solution. Each contour line corresponds to a solution to the ODE for a fixed value of C @1D.
In[8]:=
2 2
Out[8]= -
K-5 x+ O
y
-5 x+
1 y
+5
2 p x ErfiB
2
10 x
100
In[9]:=
Out[9]=
Here is the plot of the solutions to a system of two linear ODEs. The WorkingPrecision option in Plot is required because the solution is fairly complicated.
In[10]:=
sol = DSolve@8x '@tD + t * y@tD 0, 2 y '@tD - 3 x@tD 0, x@0D 1, y@0D 3<, 8x, y<, tD
1 6 AiryAiPrimeB 1 4 1 3 GammaB F + 6 323 AiryAiB 3 2
13
-3 313 AiryAiPrimeB 3 2
13
3 2
13
13
3 AiryBiPrimeB -
2 tF GammaB F F, 3 3 2
13
y FunctionB8t<,
3 AiryBiB 13
tF
2 tF GammaB F F>> 3
In[11]:=
Out[11]=
10
-2
-4
101
The ParametricPlot function can be used to trace the solution curve 8 x@tD, y@tD< in the plane.
In[12]:=
Out[12]=
-4 -2 -1 2 4
-2
-3
sol = DSolve@8x ''@tD + 3 * y@tD UnitStep@tD, x@tD - 5 * y@tD t ^ 2, x@0D 1, x '@0D 1<, 8x, y<, tD
1 96 3 5 1 480 3 5 -430 - 90 t + 81 t2 + 526 CosB 3 5 -430 - 90 t + 177 t2 + 526 CosB 3 5 3 5 3 5 tF +
62
15 SinB
tF UnitStep@-tD F,
y FunctionB8t<,
tF + 62
15 SinB
tF -
tF UnitStep@-tD F>>
In[14]:=
Out[14]=
1
-2
-1
102
Here is a plot of the solution surface for a particular choice of the arbitrary function C @1D.
In[16]:=
Plot3D@Evaluate@u@x, yD . sol . 8C@1D@t_D Sin@3 * tD<@@1DDD, 8x, - 2, 2<, 8y, - 2, 2<, Mesh FalseD
Out[16]=
To change the name of the undetermined parameter, use the GeneratedParameters option.
This changes the name of the undetermined coefficient to P@1D.
In[2]:=
The parameter C should be thought of as a pure function that acts on a set of indices to generate different constants C @iD.
This shows the behavior of C .
103
Out[5]= C@1D
In[6]:=
parameter@indexset@@3DDD
Out[6]= C@3D
Internally, the use of a pure function allows DSolve to increment the argument i in C @iD correctly for higher-order ODEs and systems of ODEs. GeneratedParameters can be specified using a pure function.
In[7]:=
Using a pure function is particularly useful if you want to begin indexing the parameters at any value other than 1 (the default).
This uses a pure function to label the parameters in the previous example const@2D and const@3D.
In[8]:=
It is sometimes useful to display the solution using subscripts or other styles for the parameter indices.
Here, the parameters are named using subscripted variables.
In[9]:=
Finally, with Module variables, you can get names for the parameters that are unique across different invocations of DSolve.
Here the same DSolve call generates different parameter names.
In[10]:=
104
In[11]:=
Here is an example of the second type. This equation has a symbolic parameter k.
In[2]:=
DSolve is equipped to deal with both types of equations. It is extremely useful to have the solution available for all possible values of the parameters in the second type of equation.
Here is a plot of the previous solution for different values of the parameter k.
In[3]:=
Out[3]=
-6
-4
-2 -10
It should be noted that the presence of symbolic parameters can lead to fairly complicated output.
105
It should be noted that the presence of symbolic parameters can lead to fairly complicated output.
This is seen in the following example (equation 2.14, page 401 of [K59]).
In[4]:= In[5]:=
2+a
H2 + aL
1 2+a
1+
a 2
2+a
c 1
2 I2+aM
x 2
1-
2+a
BesselIB
2+a 2
1 2+a
c x 2+a 1 +
1 2+a
F+
H2 + aL
c x 2+a
F C@1D GammaB
FF>>
-2 - a
2+a
However, for some special values of the parameters, the solution might be significantly simpler.
For these values of a and c, the solution is much more simple.
In[6]:=
Occasionally, a solution is valid for most, but not all, values of the parameters.
Since the input in this example is not valid at a = 0, the solution has the same limitation.
In[7]:=
1 a
In summary, the ability to solve differential equations with symbolic parameters is a powerful and essential feature of any symbolic solver such as DSolve. However, the following points should be noted. The solution might be complicated, and such calculations often require significant time and memory. The answer might not be valid for certain exceptional values of the parameters. The solution might be easy to verify symbolically for some special values of the parameters, but in the general case a numerical verification method is preferable.
106
The solution might be easy to verify symbolically for some special values of the parameters, but in the general case a numerical verification method is preferable. Numerical quantities in Mathematica can be of three types: infinite precision, machine precision, or arbitrary precision. The first type of number is referred to as exact, while the remaining two types represent incomplete information and are therefore called inexact.
Here is a simple example showing all three kinds of numbers.
In[9]:= In[10]:=
Out[10]=
In[11]:=
Out[11]//InputForm= 3.141592653589793
In[12]:=
Precision@machinepiD
Out[12]= MachinePrecision
In[13]:=
Out[13]= 3.14159265358979323846264338328
In[14]:=
Precision@highprecisionpiD
Out[14]= 30.
Since DSolve is a symbolic solver, the algorithms used by it are primarily based on the assumption of exact input. However, equations that contain inexact quantities are handled by DSolve in the usual way.
These equations contain the inexact number 3. and 3.`40, respectively.
In[15]:=
In[16]:=
Inexact input could arise, for example, when the coefficients in the equations are derived from a previous calculation and are known only approximately. In such cases, it might not be practical to convert the equations to exact form, as this could slow down the calculation significantly.
107
Here is a system of linear ODEs that all have exact coefficients. Note that even with a fairly small value of n, the calculation takes a long time to finish.
In[17]:=
n = 8; x0 @t_D := 0; xn @t_D := 1; eqns = Table@8xi '@tD - H xi+1 @tD - 2 xi @tD + xi-1 @tDL, xi @0D - H1 nL<, 8i, n - 1<D; vars = Table@xi , 8i, n - 1<D; sol = DSolve@Map@ 0 &, Flatten@eqnsDD, vars, tD; Timing
In[18]:=
LeafCount@solD
This verifies the solution. Since the solution is complicated, a numerical verification method is used.
In[19]:=
eqns . sol . 8t RandomReal@ 80, 1<, WorkingPrecision 200D< N Chop Flatten Union
Out[19]= 80<
If a single inexact quantity is introduced (in the function x0 @tD), the solution is returned more quickly.
In[20]:=
n = 8; x0 @t_D := 0.; xn @t_D := 1; eqns = Table@8xi '@tD - H xi+1 @tD - 2 xi @tD + xi-1 @tDL, xi @0D - H1 nL<, 8i, n - 1<D; vars = Table@xi , 8i, n - 1<D; sol = DSolve@Map@ 0 &, Flatten@eqnsDD, vars, tD; Timing
In[21]:=
LeafCount@solD
Out[21]= 1563
In[22]:=
eqns . sol . 8t RandomReal@ 80, 1<D < N@D & Chop Flatten Union
Out[22]= 80<
Thus, it is often desirable to continue working with inexact quantities even within a symbolic function such as DSolve. However, it should be noted that the solution obtained in such cases could have a certain amount of numerical error and should be checked carefully. It is therefore recommended that if the problem size is not too large (for instance, if there are fewer than five equations), the input should be converted to exact form using the Rationalize function.
This equation contains inexact quantities.
In[23]:=
108
Out[24]= ::x@tD
However, if initial or boundary conditions are specified, the output from DSolve must satisfy both the underlying differential equation as well as the given conditions.
Here is an example with a boundary condition.
In[2]:= In[3]:=
In[4]:=
eqns . sol
In such cases, it is useful to check whether DSolve has been asked a reasonable question~in other words, to check whether the problem is well-posed. An initial or boundary value problem is said to be well-posed if a solution for it is guaranteed to exist in some well-known class of functions (for example, analytic functions), if the solution is unique, and if the solution depends continuously on the data. Given an ODE of order n (or a system of n first-order equations) and n initial conditions, there are standard existence and uniqueness theorems that show that the problem is well-posed under a specified set of conditions. The right-hand side of the first-order linear ODE in the previous example is a polynomial in y@xD and hence infinitely differentiable. This is sufficient to apply Picards existence and uniqueness theorem, which only requires that the right-hand side be Lipschitz-continuous. Most problems that arise in practice are well-posed since they are derived from sound theoretical principles. However, as a note of caution, the following are examples where DSolve might have difficulty finding a satisfactory solution to the problem.
109
Most problems that arise in practice are well-posed since they are derived from sound theoretical principles. However, as a note of caution, the following are examples where DSolve might have difficulty finding a satisfactory solution to the problem.
Here is the solution to a first-order ODE in which the right-hand side fails to satisfy the Lipschitz condition around 0.
In[5]:=
2 1
Out[6]=
-1 -1 -2
This initial value problem is well-posed in a region around the initial condition and hence DSolve succeeds in picking out the correct branch for the given initial condition.
In[7]:=
1 + 2 x F>>
Here is a second-order ODE. The boundary conditions do not allow any solution to this problem.
In[8]:=
Out[8]= 8<
In this example, DSolve returns a pair of solutions. As the table shows, the first solution is only valid for values of x greater than or equal to 2.
In[9]:=
110
In[10]:=
In[11]:=
Out[11]= 88False, True<, 8False, True<, 8True, True<, 8True, True<, 8True, True<, 8True, True<<
Finally, it is possible that a problem has a solution, but that DSolve fails to find it because the general solution is in implicit form or involves higher transcendental functions.
In this example, a solution is available only after inverting the roles of the dependent and independent variables.
In[12]:=
Out[12]= 8<
In[13]:=
This concludes the discussion of the basic principles for effectively working with DSolve. See the list of "references" that were found to be useful either during the development of DSolve or during the preparation of this documentation.
111
References
[AB04] Abell, M. L. and J. P. Braselton. Differential Equations with Mathematica, 3rd ed. Elsevier Academic Press, 2004. [A89] Abramov, S. A. "Rational Solutions of Linear Differential and Difference Equations with Polynomial Coefficients." USSR Comput. Maths. Math. Phys. 29 (1989): 7|12. [A96] Abramov, S. A. "Symbolic Search Algorithms for Partial d'Alembertian Solutions of Linear Equations." Programming and Computer Software 22, no. 1 (1996): 26. [AB01] Abramov, S. A. and M. Bronstein. "On Solutions of Linear Functional Systems." In Proc. ISSAC'01, 1|6, 2001. [AK91] Abramov, S. A. and K. Yu. Kvansenko. "Fast Algorithms to Search for the Rational Solutions of Linear Differential Equations with Polynomial Coefficients." In Proc. ISSAC'91, 267|270, 1991. [AP94] Abramov, S. A. and M. Petkovsek. "D'Alembertian Solutions of Linear Differential and Difference Equations." In Proc. ISSAC'94, 169|174, 1994. [ABP95] Abramov, S. A., M. Bronstein, and M. Petkovsek. "On Polynomial Solutions of Linear Operator Equations." In Proc. ISSAC'95, 290|296, 1995. [B93] Bocharov, A. "Symbolic Solvers for Nonlinear Differential Equations." The Mathematica Journal 3, no. 2 (1993): 63|69. [BD97] Boyce, W. F. and R. C. DiPrima, Elementary Differential Equations. John Wiley and Sons, 1997. [BM91] Boyer, C. B. and U. C. Merzbach, A History of Mathematics, 2nd ed. John Wiley, 1991. [B91] Bronstein, M. "The Risch Differential Equation on an Algebraic Curve." In Proc. ISSAC'91, 241|246, 1991. [B92] Bronstein, M. "On Solutions of Linear Ordinary Differential Equations in Their Coefficient Field." J. Symbolic Computation 13 (1992): 413|439. [B92a] Bronstein, M. "Integration and Differential Equations in Computer Algebra." Programming and Computer Software 18, no.5 (1992): 201|217. [B92b] Bronstein, M. "Linear Ordinary Differential Equations: Breaking Through the Order 2 Barrier." In Proc. ISSAC'92, 42|48, 1992.
112
[B92b] Bronstein, M. "Linear Ordinary Differential Equations: Breaking through the Order 2 Barrier." In Proc. ISSAC'92, 42|48, 1992. [C80] Campbell, S. L. Singular Systems of Differential Equations I. Pitman, 1980. [C82] Campbell, S. L. Singular Systems of Differential Equations II. Pitman, 1982. [CC04] Chan, L. and E. S. Cheb-Terrab. "Non-Liouvillian Solutions for Second Order Linear ODEs." In Proc. ISSAC'04, 80|86, 2004. [CDM97] Cheb-Terrab, E. S., L. G. S. Duarte, and L. A. C. P. da Mota. "Computer Algebra Solving of First Order ODEs Using Symmetry Methods." Comp. Phys. Comm. 101 (1997): 254. [CR99] Cheb-Terrab, E. S. and A. D. Roche. "Integrating Factors for Second Order ODEs." J. Symbolic Computation 27 (1999): 501. [CR00] Cheb-Terrab, E. S. and A. D. Roche. "Abel ODEs: Equivalence and Integrable Classes." Comp. Phys. Comm. 130 (2000): 204. [D58] Drazin, M. P. "Pseudo Inverses in Associative Rays and Semigroups" American Mathematical Monthly 65 (1958): 506|514. [F59] Forsyth, A. R. Theory of Differential Equations. Dover, 1959. [I99] Ibragimov, N. H. Elementary Lie Group Analysis and Ordinary Differential Equations. John Wiley & Sons, 1999. [I44] Ince, E. L. Ordinary Differential Equations. Dover, 1944. [K59] Kamke, E. Differentialgleichungen: Losungsmethoden und Losungen. Akademische Verlagsgesellschaft, 1959. [K74] Kamke, E. Differentialgleichungen Losungsmethoden und Losungen, Bd. II: Partielle differentialgleichungen. Chelsea Publishing Co., 1974. [K00] Kevorkian, J. Partial Differential Equations: Analytical Solution Techniques. SpringerVerlag, 2000. [K72] Kline, M. Mathematical Thought from Ancient to Modern Times, Vol. 2. Oxford University Press, 1972. [K86] Kovacic, J. J. "An Algorithm for Solving Second Order Linear Homogeneous Differential Equations." J. Symbolic Computation 2 (1986): 3|43. [L01] Kovacic, J. J. "An Algorithm for Solving Second Order Linear Homogeneous Differential Equations." Lecture, City College of New York, 2001.
113
[L01] Kovacic, J. J. "An Algorithm for Solving Second Order Linear Homogeneous Differential Equations." Lecture, City College of New York, 2001. [KPS03] Kythe, P. K., P. Puri, and M. R. Schferkotter, Partial Differential Equations and Boundary Value Problems with Mathematica, 2nd ed. Chapman and Hall/CRC, 2003. [L65] Lebedev, N. N. Special Functions and Their Applications. Prentice-Hall, 1965. [M00] Meyer, C. D. Matrix Analysis and Applied Linear Algebra. SIAM, 2000. [M60] Murphy, G. M. Ordinary Differential Equations and Their Solutions. Van Nostrand, 1960. [M47] McLachlan, N. W. Theory and Application of Mathieu Functions. Oxford University Press, 1947. [O95] Olver, P. J. Equivalence, Invariants and Symmetry. Cambridge University Press, 1995. [PZ95] Polynanin, A. D. and V. F. Zaitsev, Handbook of Exact Solutions for Ordinary Differential Equations. CRC Press, 1995. [S81] Saunders, B. D. "An Implementation of Kovacic's Algorithm for Solving Second Order Linear Homogeneous Differential Equations." In Proc. SYMSAC'81 (P. Wang, ed.), 105, 1981. [S85] Schlesinger, L. Handbuch der Theorie der Linearen Differentialgleichungen. Teubner, 1985. [SS98] Shirvani, M. and J. W.-H. So. "Solutions of Linear Differential Algebraic Equations." SIAM Review 40, no. 2 (1998): 344|346. [S57] Sneddon, I. Elements of Partial Differential Equations. McGraw-Hill, 1957. [T05] Trott, M. The Mathematica GuideBook for Symbolics. Springer-Verlag, 2005. [UW96] Ulmer, F. and J-A. Weil. "Note on Kovacic's Algorithm." J. Symbolic Computation 22 (1996): 179|200. [WW27] Whittaker, E. T. and G. N. Watson. A Course of Modern Analysis, 4th ed. Cambridge University Press, 1927. [W02] Wolfram, S. A New Kind of Science. Wolfram Media, Inc., 2002. [W04] Wolfram, S. The Mathematica Book, 5th ed. Wolfram Media, Inc., 2004. [Z89] Zwillinger, D. Handbook of Differential Equations. Academic Press, 1989