Wolfram Mathematica Tutorial Collection - Differential Equation Solving With DSolve (2008) (p118)
Wolfram Mathematica Tutorial Collection - Differential Equation Solving With DSolve (2008) (p118)
DIFFERENTIAL EQUATION
SOLVING WITH DSOLVE
Contents
Introduction to Differential Equation Solving with DSolve . . . . . . . . . . . . . . . . . . . . . .
11
Overview of ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
First-Order ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
24
33
Higher-Order ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
36
Systems of ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
42
50
55
Introduction to PDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
55
First-Order PDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
56
Second-Order PDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
66
70
Introduction to DAEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
70
Examples of DAEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
71
76
76
77
82
85
89
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
89
90
94
98
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[1]= 99y@xD C@1D==
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]=
3
2
1
-3
-2
-1
DSolve@eqn,y,xD
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".
F>>
1-x
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]:=
ArcTan@tD t 0
-t
True
+2t
LogA1 + t2 E t 0
True
F,
2 I1 + t2 M
4+t-2t
ArcTan@tD t 0
-t
True
+2
y FunctionB8t<,
LogA1 + t2 E t 0
True
F>>
2 I1 + t M
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
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
-x + y
FF>>
xy
This obtains a particular solution to the PDE for a specific choice of C@1D.
In[14]:=
Out[14]= -x y
-x + y
+ SinB
H-x + yL2
10 x y
x2 y2
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]:=
g FunctionB8x<,
1
2
1
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
-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
>>
C@1D - Log@xD
Out[2]= ::y@xD -
x2
16
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
FF>,
6 + C@1D
12
H6 + C@1DL Hx + C@2DL2 ,
FF>>
6 + C@1D
This plots the solutions. The discontinuity in the graphs at x = -3 results from the choice of
inverse functions used by Solve .
In[4]:=
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
H-1 + x + y@xDL2 3 +
2 H2+3 xL
-1+x+y@xD
H2+3 xL K-2+
-1+x+y@xD
F - LogB
2+3 x
-1+x+y@xD
F C@1D +
H2 + 3 xL
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]:=
-7 x
C@1D + x C@2D + 3 x C@3D==
Out[7]= 99y@xD
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
9261
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
Out[9]= ::y@xD
-2-2
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]:=
3
, ArcCos@tDF + C@2D MathieuSB5, - , ArcCos@tDF>>
2
2
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]:=
3
2
3
, xF + C@2D MathieuSB5, - , xFF>>
2
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<,
1
2
1
4-x
1 - x2 - ArcSin@xD F>,
4+x
1 - x2 + ArcSin@xD F>>
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
1691
G. Leibniz
Homogeneous
y HxL
1691
G. Leibniz
1694
G. Leibniz
Bernoulli
1695
James Bernoulli
Riccati
1724
Count Riccati
1734
L. Euler
1734
A-C. Clairaut
1743
L. Euler
x
f J yHxL N
M d x + N d y 0 with
Clairaut
HnL
Hn-1L
y HxL + an-1 y
M
y
N
x
with a1 constant
Hypergeometric
1769
L. Euler
Legendre
1785
M. Legendre
Bessel
1824
F. Bessel
Mathieu
1868
E. Mathieu
Abel
1834
N. H. Abel
Chini
1924
M. Chini
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]:=
1
2
1 + x2 +
ArcSinh@xD
2
13
Here is a plot of the integral curves for different values of the arbitrary constant C@1D.
In[2]:=
tab = Table@y@xD . sol@@1DD . 8C@1D -> k<, 8k, - 80, 80, 40<D;
In[3]:=
300
200
Out[3]=
100
10
12
14
16
18
-100
Separable Equations
The general solution to this equation is found by separation of variables.
In[1]:=
DSolveBy @xD
x2 y@xD ^ 2
, y, xF
3 - x2
2
3-x
F>>
- 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
, y, xF
3 - x2
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
x2
, y@xD, xF
Log@y@xDD * Sin@y@xDD
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
-3 + x x
3 + x + 9 ArcSinhB
-3 + x
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]:=
x2
x2
+ x6 C@1D F>>
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
Out[5]=
0.5
1.0
1.5
-2
-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
x2
2
C@1D +
x2
- -
p
ErfiB
2
3+x
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]:=
-x
-x
K@1D
Q@K@1DD K@1D>>
Out[2]= ::y@xD C@1D +
1
A more traditional form of the solution can be obtained by replacing K@1D with a variable such
as t.
In[3]:=
-x
-x
t
Out[3]= ::y@xD C@1D + Q@tD t>>
1
16
Out[1]= SolveBx
1
2
y@xD2
C@1D +
y@xD2
- -
p
ErfiB
3 + y@xD
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]:=
3
3
Out[1]= 11 x y@xD + y @xD x y@xD
In[2]:=
sol = DSolve@eqn, y, xD
11
F>, :y FunctionB8x<,
2
1 + 11 x2 + 121 11 x C@1D
11
F>>
2
1 + 11 x2 + 121 11 x C@1D
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 -
14
714 x13
:y@xD
14
>,
14
714 x13
>, :y@xD
714 x13
>>
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 -
3 x5 - 2 C@1D
>>
3 x6 + 3 x C@1D
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]:=
In[3]:=
3
, xF + C@2D LegendreQB , xF>>
2
2
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]:=
RightHandSideCoeffs = 83 x, 5, - H3 x + 5L<;
In[6]:=
Total@RightHandSideCoeffs D
Out[6]= 0
In[7]:=
sol = DSolve@eqn, y, xD
-5 x-3 x
C@1D +
1
12
-6
-x H5+3 xL
+5
2512
F>>
3 p ErfB
5+6 x
2
Out[8]= 8True<
Exact Equations
Here is an example of an exact ODE.
In[1]:=
In[2]:=
In[3]:=
Out[3]= 0
In[4]:=
Out[4]= y @xD
11 + 5 x2 - 2 y@xD2
3 + Sin@y@xDD + 4 x y@xD
In[5]:=
Out[5]= SolveB-11 x -
5 x3
3
19
11 + 5 x2 - 2 y@xD2
>>
3 + Sin@y@xDD + 4 x y@xD
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]:=
C@1D
+ x C@1D + C@1D2 ==
Out[1]= 99y@xD
Out[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.
1
; f2 = - 3; f3 = x;
In[1]:=
f0 = 0; f1 =
In[2]:=
Invariant = f0 f32 +
2 f23
- f1 f3 f2 - x f3 f2 + f3 x f2
Out[2]= 0
In[3]:=
Out[3]= y @xD
y@xD
- 3 y@xD2 + x y@xD3
x
In[4]:=
sol = DSolve@AbelODE, y, xD
x
x2
In[5]:=
1
x2
F>, :y FunctionB8x<,
x
x2
+ C@1D
1
x2
F>>
+ C@1D
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.
Out[7]= SolveB
1-x+
1
y@xD
-1 + x
+ C@1D + ExpIntegralEiB1 - x +
F 0, y@xDF
y@xD
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 ==
2
Out[8]= y @xD -y@xD +
y@xD3
8 x2
- y@xD2
y@xD3
8 x2
In[9]:=
Out[9]= SolveB
H-1L23
C@1D + AiryAiPrimeB-
+ -H-2L13 x +
H-2L13
H-1L23
F + AiryAiB-
H-1L23
AiryBiPrimeB-
y@xD
H-1L23
H-2L13
+ -H-2L13 x +
F -H-2L13 x +
y@xD
2 213 x
+ -H-2L13 x +
H-2L13
H-2L13
y@xD
2 213 x
2
F+
y@xD
2 213 x
+ -H-2L13 x +
AiryBiB-
y@xD
2 213 x
-H-2L13 x +
H-2L13
H-2L13
0, y@xDF
y@xD
1
8
y@xD2 -8 +
y@xD
>>
x2
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
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.
2x
+ x ^ 3 + y@xD
, y@xD, xF
y@xD
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
Out[11]= SolveBC@1D -1 +
2 14
2 y@xD
x2
3x
3x
Hypergeometric2F1B ,
3
2
3x
2 y@xD
x2
2
3x
2 y@xD
x2
, y@xDF
2 14
2
2 1-
2
3x
2 y@xD
x2
2x
9
+ x3
>>
y@xD
Chini Equations
Chini equations are a generalization of Abel and Riccati equations.
This solves a Chini equation.
In[1]:=
LogB-1 + J N
14 34
5
1 - 45 14 &,
Out[1]= SolveB-45 RootSumB-45 + 3
14
Ix43 M
14
14
Log@xD
, y@xDF
13
y@xDF
&F
23
24
-6 x
C@1D + x C@2DE==
Out[1]= 99y FunctionA8x<,
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]:=
3x
3x
Out[4]= 99y FunctionA8x<, C@1D + x C@2DE==
In[5]:=
3x
3x
Out[5]= 2 + 3 x
x2
C@1D CosB
Out[6]= ::y FunctionB8x<,
3 x
F + x2 C@2D SinB
2
In[7]:=
x2
CosB
Out[7]= 2
3 x
F + 3 x2 SinB
3 x
15
10
Out[8]=
-0.4
-0.2
0.2
3 x
0.4
FF>>
26
Out[1]= ::y@xD
>>
x2
x2
The Legendre linear equation is a generalization of the Euler equation. It is an ODE of the form
Hc x + dL2 y HxL + a Hc x + dL y HxL + b yHxL 0.
Here is an example of a Legendre linear equation.
In[2]:=
Out[2]= ::y@xD
1
3
5 Log@1 + 3 xDF
H1 + 3 xL13
C@1D SinB
+
1
3
5 Log@1 + 3 xDF
>>
H1 + 3 xL13
a0 = 1;
In[2]:=
a1 = Log@xD;
In[3]:=
a2 = 1 x;
In[4]:=
In[5]:=
27
Out[5]= True
In[6]:=
sol = DSolve@eqn, y, xD
x
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<,
1
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]=
-14.5
-14.0
-13.5
-13.0
-12.5
-12.0
-0.1
-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
10
-0.2
3
, xF + C@2D LegendreQB , xF>>
4
4
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
Out[7]= :
,
x
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
n
2
, x2 F>>
With n set to 5, the solution is given in terms of polynomials, exponentials, and Erfi .
In[9]:=
Out[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
C@2D J8 x - 18 x x2 + 4 x x4 +
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]:=
H-2 Log@-1+xD-Log@xDL
C@1D Hypergeometric2F1B- , - , - , xF
18
H-1L14 4
H-2 Log@-1+xD-Log@xDL
3 7 9
x98 C@2D Hypergeometric2F1B , , , xFF>>
8 8 4
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
a x1+c
-I1+cM2
C@1D HypergeometricUB-
-c
2+2c
1+c
a x1+c
-H1 + cL
-c
F + C@2D LaguerreLB
, -
1
1+c
2+2c
a x1+c
-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
5 x3
3
C@1D +
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]:=
Out[6]= ::y@xD
-7 x4
C@1D -
7x
4
FN
>>
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
1.0
-0.5
5 x
F C@1D + 2 BesselKB0,
5 x
F C@2DF>>
This equation (equation 2.437, page 507 of [K59]) has trigonometric coefficients. The solution
is given in terms of elementary functions.
In[2]:=
13
- -
+ C@1D Cos@xD
13
- +
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]:=
In[5]:=
sol = DSolve@expr 0, y, xD
l LogA-b x E
C@1D HypergeometricUB-
-b + 2
d -2
, 1+
2b
-
d -b x +
l LogA-b x E
C@2D LaguerreLB
-b + 2
d -2
2b
F+
d -b x
-b x
FF>>
Out[6]= 0
Out[1]= ::y@xD
x C@1D CosB
3 Log@xDF +
2
x C@2D SinB
3 Log@xDF +
x2 CosB
3 Log@xDF + x2 SinB
3 Log@xDF
>>
Out[2]= ::y@xD
x C@1D CosB
1
2
3 Log@xDF +
x C@2D SinB
3 Log@xDF>>
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
Out[3]= :
x SinB
3 Log@xDF +
2
1
3 Log@xDF +
2
x SinB
3 Log@xDF +
x CosB
x CosB
x2 CosB
x2 CosB
x2 CosB
3
3
3 Log@xDF + 2
x SinB
,
2
3 Log@xDF
2
2
3 Log@xDF + x2 SinB
3 Log@xDF
2
3 Log@xDF +
x2 CosB
3
1
3 Log@xDF + x2 SinB
3 Log@xDF
3 Log@xDF +
2
1
3 Log@xDF + x2 SinB
3 Log@xDF
, 3
x CosB
2
3 Log@xDF +
2
In[4]:=
3 Log@xDF + x2 SinB
2
x SinB
3 Log@xDF
2
x SinB
3 Log@xDF +
2
1
3 Log@xDF + x2 SinB
2
3
x2 CosB
x SinB
1
3
3 Log@xDF +
x2 CosB
3 Log@xDF + x2 SinB
3 Log@xDF
>
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]:=
10 p ErfiB
xFFF>>
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
0.2
0.4
0.6
0.8
1.0
-1
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
13
2
3
:y@xD LogB
2 13
C@1D Hx + C@2DL2 F
F>,
13
2 13
C@1D Hx + C@2DL2 F
F>,
:y@xD LogBH-1L23
13
2 13
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]:=
Out[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
-2 x
-2 x
C@1D F +
-3 + 2
-2 x
-2 x
C@1D F
2
3
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
C@2D
>>
H4 x + 7 C@1DL74
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]:=
Out[8]= ::y@xD -
2 p C@2D -
313
2 p I-x3 M
23
x3
C@1D GammaB ,-
x2
F>>
2 InverseErfB
3p
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
-4 x
C@1D + x C@2D + 7 x C@3D==
Out[1]= 99y@xD
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]:=
3x
3x
5x
5x
Out[2]= 99y@xD C@1D + x C@2D + C@3D + x C@4D==
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]:=
2x
2x
7x
3x
3x
Out[4]= 99y@xD C@3D + x C@4D + C@5D + C@2D Cos@xD + C@1D Sin@xD==
DSolve@
x ^ 4 * y ''''@xD - 2 * x ^ 3 * y '''@xD - x ^ 2 * y ''@xD + 5 * x * y '@xD + y@xD 0, y@xD, xD
2
RootA1-4 1+16 1
Out[1]= ::y@xD x
-8 13 +14 &,1E
C@3D + x
-8 13 +14 &,2E
C@2D +
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 + dLn yHnL HxL + a1 Hc x + dLn-1 yHn-1L HxL + a2 Hc x + dLn-2 yHn-2L HxL + an yHxL 0.
This is a Legendre linear equation.
In[2]:=
RootA1-570 1+1044 1
Out[2]= ::y@xD H5 + 3 xL
H5 + 3 xL
C@3D + H5 + 3 xL
C@2D +
C@4D>>
a0 = 1;
In[2]:=
a1 = - 1 ;
In[3]:=
a2 = 5 x;
In[4]:=
a3 = 5;
In[5]:=
H3L
Out[5]= 5 y@xD + 5 x y @xD - y @xD + y @xD
Out[6]= 0
39
sol = DSolve@ExactODE 0, y, xD
H-1L13 J
x2
AiryAiBOut[7]= ::y FunctionB8x<,
1
4
H-1L13 J
- 5 xN
F C@2D + x2 AiryBiB-
523
H-1L
x2
13
AiryBiB-
1
4
- 5 xN
523
H-1L13 J
AiryAiB-
1
4
523
H-1L23
F C@3D +
H-1L13 K -5 K@2DO
KA2E
2
p AiryAiB-
523
F C@1D
K@2D +
513
H-1L23
- 5 xN
523
F -
- 5 xN
H-1L13 K -5 K@1DO
KA1E
2
p AiryBiB-
523
F C@1D
K@1D F>>
513
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==
sol2 = DSolve@
x ^ 3 * y '''@xD + 3 * x ^ 2 * y ''@xD + H4 x ^ 3 - 11 xL * y '@xD + 4 x ^ 2 * y@xD == 0, y, xD
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]:=
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;
In[5]:=
sol3 = DSolve@HypergeometricPFQTypeEquation 0, y, xD
1
11
15
>, xF
+
x43
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
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
-4 + x2
F>>
-4 + x2
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]:=
-x
3x
11 x
C@3D +
Out[8]= ::y@xD C@1D + C@2D +
17 Cos@2 xD + 6 Sin@2 xD
>>
1625
generalsolution =
y@xD . DSolve@y '''@xD - 13 * y ''@xD + 19 * y '@xD + 33 * y@xD 0, y@xD, xD@@1DD
-x
3x
11 x
C@3D
Out[9]= C@1D + C@2D +
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
Out[11]= ::y@xD -
C@2D
+ C@3D>>
3 H4 x + 7 C@1DL34
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 XHtL +BHtL.
Here XHtL 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.
In[2]:=
Eigenvalues@AD
In[3]:=
In[4]:=
43
This solves the system. Note that the general solution depends on two arbitrary constants C@1D
and C@2D.
In[5]:=
t
t
t
t
Out[5]= 99x FunctionA8t<, I-2 + 3 M C@1D - 6 I-1 + M C@2DE,
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;
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]:=
Eigenvalues@AD
Out[9]= 81 + 2 , 1 - 2 <
In[10]:=
In[11]:=
44
t
t
Out[12]= ::x FunctionA8t<, -4 C@2D Sin@2 tD + C@1D HCos@2 tD + 3 Sin@2 tDLE,
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;
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]:=
In[16]:=
45
3 t
C@3D Cos@tD + 2
3 t
Cos@tD +
3 t
Cos@2 tD +
3
1
96
1
3 t
C@6D Cos@tD + 2
3 t
Cos@tD - 2
3 t
Cos@2 tD +
3 Sin@tD -
3 2
3 t
Sin@tD +
3 t
C@1D Cos@tD + 2
3 t
Cos@tD - 2
3 t
Cos@2 tD -
3 Sin@tD +
3 2
3 t
Sin@tD +
24
1
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]:=
-Cos@tD
C@1DE, y FunctionB8t<, 3 C@2DF>>
Out[18]= ::x FunctionA8t<,
The rows of the coefficient matrix for this system form an orthogonal set of vectors.
In[19]:=
In[20]:=
A.Transpose@AD Det@AD
46
In[21]:=
In[22]:=
t
Out[22]= 9x @tD x@tD + Tan@tD y@tD, y @tD -Tan@tD x@tD + y@tD=
In[23]:=
Here is a system of three first-order ODEs. The coefficient matrix is upper triangular.
In[25]:=
In[26]:=
MatrixForm@AD
Out[26]//MatrixForm=
t 2 3
0 2 -1
0 0 1
In[27]:=
In[28]:=
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]:=
t
Out[29]= ::x FunctionB8t<, C@1D + 2 I-1 - M C@2D - 5 C@3DF,
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]:=
DSolveB:y @xD
w @xD
I- 3 - 2 x + x2 M I- 1 + x3 M
I1 + 20 x2 + 3 x3 M w@xD
H5 + xL I- 1 + x3 M
I6 + 2 x - 3 x3 - x5 M y@xD
H5 + xL w@xD
x C@1D
-3 - 2 x + x2
x I- 3 - 2 x + x2 M I- 1 + x3 M
4 x I- 3 - 2 x + x2 M y@xD
-
H5 + xL I- 1 + x3 M
x2 C@2D
-3 - 2 x + x2
F, w FunctionB8x<,
C@1D
5+x
x4 C@2D
F>>
5+x
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]:=
In[32]:=
y FunctionB8t<,
H-2 - tL C@1D
t3
H4 + tL C@1D
- 2 -t C@2DF,
t2
t3
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]:=
B = 8E ^ Ht 10L, t<;
In[36]:=
In[37]:=
t10
+ 7 x@tD - 8 y@tD, y @tD t + 5 x@tD - 5 y@tD=
Out[37]= 9x @tD
48
In[38]:=
500
-9 t10 Cos@2 tD -
481
1
-t H18 + 70 tL Cos@2 tD +
50
225
-9 t10 Sin@2 tD -
481
-t H-26 + 10 tL Sin@2 tD +
50
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
t HCos@2 tD + 3 Sin@2 tDL
510
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]:=
Out[40]=
60
40
20
0.5
1.0
1.5
2.0
2.5
3.0
-20
system =
8p '@xD == 1, q '@xD == x, r '@xD == 0, s '@xD == r@xD Hp@xD + 4 * q@xD * r@xDL<;
In[2]:=
x2
+ C@2DF,
2
2 ArcTanB
1+4 x C@3D
F C@3D
49
+ 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]:=
Out[5]= :v FunctionB8x<,
6 213 C@1D
4 C@1D2 + 4 C@1D
16
-324 x +
13
-324 x +
13
6 213 C@1D
13
-324 x +
-324 x +
u FunctionB8x<,
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.
m = x * Cos@tD + y * Sin@tD;
In[2]:=
n = - x * Sin@tD + y * Cos@tD;
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
-1
-2
-3
51
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]:=
Simplify@M@a + bD == M@aD.M@bDD
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]:=
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
In[15]:=
m = x * E ^ t;
In[16]:=
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]:=
Riccatiexpression = p + y ^ 2 - H1 x ^ 2L;
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]:=
In[24]:=
In[25]:=
sol = DSolve@FirstOrderODE, y, xD
-2
Out[25]= 99y FunctionA8x<,
-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;
In[29]:=
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.
x LogB6 -
C@1D
- 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]:=
Clear@u, vD
In[33]:=
In[34]:=
u FunctionB8x<, x +
C@1D TanB
2
1
2 x
C@1D + 2
2 x
C@1D + 2
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]:=
I-x2 + 2 yMF
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
classification
transport equation
u
x
Burgers equation
u
t
eikonal equation
J x N + J y N 1
Laplaces equation
2 u
wave equation
2 u
heat equation
2 u
+c
u
y
0 with c constant
+u
u
x
u 2
x2
x2
u 2
2 u
y2
= c2
=k
2 u
t2
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
aHx, yL
uHx, yL
x
+ bHx, yL
uHx, yL
y
57
uHx, yL
x
uHx, yL
y
z = uHx, yL; p =
uHx, yL
x
; q =
uHx, yL
y
z := u@x, yD
In[2]:=
p := D@u@x, yD, xD
In[3]:=
q := D@u@x, yD, yD
In[4]:=
eqn = 2 * p + 3 * q + z 0;
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.
-x2
C@1DB
Out[5]= ::u FunctionB8x, y<,
H-3 x + 2 yLFF>>
Out[6]= True
Particular solutions of the homogeneous PDE are obtained by specifying the function C@1D.
In[7]:=
-x2
SinB
Out[7]=
1
2
H-3 x + 2 yLF
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;
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]:=
-x7
C@1DB
Out[11]= -10 + x + y +
H-3 x + 7 yLF
eqn = Sin@xD * p + E ^ x * q 0;
In[13]:=
H1+L x
Hypergeometric2F1B
Out[13]= ::u FunctionB8x, y<, C@1DBy + H1 + L
, 1,
2
3
2
, 2 x FFF>>
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]:=
I-x2 + 2 yMFF>>
eqn = p + x * q z ^ 2 + 5;
In[18]:=
5 TanB
5 x+
5 C@1DB
I-x2 + 2 yMFFF>>
Out[19]= True
59
60
uHx, yL
x
+ uHx, yL
uHx, yL
y
BurgersEquation = p + z q 0;
In[23]:=
In[24]:=
p1 + z * q1
Out[24]= 0
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]:=
z := u@x, yD
In[2]:=
p := D@u@x, yD, xD
In[3]:=
q := D@u@x, yD, yD
In[4]:=
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]:=
+ y C@2DF>>
C@2D
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
+ C@1D + 5 y C@1D
5 C@1D
In[8]:=
oneparameterenvelope =
Eliminate@8oneparametersol, D@oneparametersol, C@1DD<, 8C@1D<D
2
Out[8]= 5 u@x, yD x H4 + 20 yL
In[10]:=
Out[10]=
u@x, yD
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]:=
In[13]:=
Out[13]= u@x, yD
In[14]:=
envelopeoftwoparameterfamily =
Eliminate@8twoparameterfamily, D@twoparameterfamily, C@1DD,
D@twoparameterfamily, C@2DD<, 8C@1D, C@2D<D
Out[14]= u@x, yD 1
Thus, the singular integral for this PDE is a plane parallel to the x-y plane.
F>>
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]:=
1 - C@2D2 F>,
1 - C@2D2 F>>
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
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]:=
Separable = p ^ 2 + a * q x + 3 y;
In[22]:=
:u FunctionB8x, y<,
3 y2
2a
3 y2
2a
2
3
2
Hx - C@1DL32 +
Hx - C@1DL32 +
y C@1D
a
y C@1D
+ C@2DF>,
+ C@2DF>>
In this example (equation 6.49, page 202 of [K74]), the independent variables x and y are not
explicitly present.
In[24]:=
MissingIndependentVariables = a * p ^ 2 + b * p * q c * z ^ 2;
In[25]:=
c y
-b CA1E-a
CA1E2
c x CA1E
-b CA1E-a
CA1E2
c CA2E
-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 Hp, 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]:=
b LogB
x2 + y2 F
C@1D LogB
-
C@1D + C@2D +
x2 + y2 F
>>
This equation (equation 6.36, page 196 of [K74]) can be transformed into a linear PDE using a
Legendre transformation.
In[29]:=
LegendreTransformable = y * p * q - z * p + a * q 0;
In[30]:=
-y H-2 x + 2 C@2DL -
F>, :u
4 C@1D
FunctionB8x, y<,
1
4 C@1D
-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
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
+b
2 u
xy
+ c
2 u
y2
+ d
u
x
+e
u
y
+ 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
+b
2 u
xy
+c
2 u
y2
= 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]:=
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]:=
-1 +
59
x + yF + C@2DB
-1 -
59
x + yFF>>
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]:=
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]:=
7+
57
x + yF + C@2DB-
1
4
7-
57
x + yFF>>
69
Out[12]= 8True<
a = 3; b = 30; c = 75; b ^ 2 - 4 a * c
Out[13]= 0
In[14]:=
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;
In[15]:=
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]:=
-t C@1DF, y FunctionB8t<, -
-t C@1DF>>
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 +
-t C@1D -
Cos@tD
Sin@tD
, -
-t C@1D +
Cos@tD
Sin@tD
>
In[7]:=
-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.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]:=
g @tD
2
In[12]:=
h @tD
10
F, y FunctionB8t<,
g@tD
2
h @tD
10
F, z FunctionB8t<,
h@tD
F>>
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]:=
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]:=
2 t3
C@2D +
Out[17]= ::x1 FunctionB8t<, -C@1D - 3
I-1 + 2 t3 M C@2DF,
2
x2 FunctionB8t<, -9 2 t3 C@2D + 2 C@1D -
I-1 + 2 t3 M C@2D F,
2
x3 FunctionB8t<, -C@1D + 18 2 t3 C@2D +
I-1 + 2 t3 M C@2DF>>
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]:=
In[20]:=
176
74
In[22]:=
In[23]:=
176
In[25]:=
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]:=
Clear @p, q, rD
In[28]:=
In[29]:=
75
Out[29]= :9.156,
::p FunctionB8t<, -
5 N J1 +
5 J-1 +
1
5 2
33 2
5 t
2
-1+
1
2
-1-
q FunctionB8t<,
4 -410 - 17 2
t
+ 440 2
t
5 t
2
1
2
-1-
-1-
+9
5 2
-1-
- 17 2
-1+
+ 20 t - 34 Cos@tD +
t
5 N
20 + 14 2
-1-
-4
5 2
-1-
5 t
-1-
+ 14 2
-1+
Sin@tD F,
+4
5 2
-1+
5
t
20 2
5 t
2
1
2
-1-
r FunctionB8t<,
3 2
- 3 2
-1-
5 t
1
2
-1-
-5
5 2
Cos@tD - 2
-1-
+ 3 2
5 t
2
-1+
-1-
Sin@tD F,
1
+5
5 2
-1+
5
t
5 Cos@tD - 2
In[30]:=
5 t
2
1
2
-1-
Cos@tD + 3 2
5 t
2
1
2
-1-
Sin@tD F>>>
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
In[2]:=
Out[2]= ::y@tD
3 t2
C@1D +
ErfB
tF>>
3 t2
24 +
6 p ErfB
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]:=
1
6
3 t2
6a+
6 p ErfB
3
2
tF F>>
77
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]:=
generalsolution = DSolve@linearsecondorderODE, x, tD
-3 t
C@1D + -2 t C@2DE==
Out[9]= 99x FunctionA8t<,
In[10]:=
-3 t
I-3 + 4 t ME==
Out[10]= 99x FunctionA8t<,
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.4
0.2
0.5
1.0
1.5
2.0
-0.2
To get more information about the solutions for the problem, set x @0D == x0.
In[15]:=
-3 t
I-2 + 3 t - x0 + t x0ME==
Out[15]= 99x FunctionA8t<,
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]:=
Out[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
x0= -1
x0= 0
x0= 1
In[18]:=
generalsolution = DSolve@inhomogeneousequation, y, xD
1
2
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]:=
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
In[26]:=
In[27]:=
In[28]:=
17
1
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
-2
-4
1.0
82
In[31]:=
0.04
Out[31]= 0.02
0.00
0.25
0.10
0.05
0.20
0.00
0.05
0.15
In[2]:=
DSolve@LogisticEquation, y, tD
r t+K C@1D K
F>>
-1 + r t+K C@1D
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]:=
F>>
1 - a + a r t
This verifies that the solution satisfies the equation and the initial condition.
In[5]:=
Out[6]=
5
4
3
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]:=
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 @InfinityD 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 @InfinityD 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-
JacobiSNB
x2 + x2
1-
1 - C@1D
1+
1 - C@1D
JacobiSNB
1 - C@1D
1+
1 - C@1D
1 - C@1D
1+
1 - C@1D
1 - C@1D + 2 x C@2D + 2 x
1
1-
1 - C@1D + 2 x C@2D + 2 x
1 - C@1D C@2D2 ,
1 - C@1D
1
1-
1 - C@1D + 2 x C@2D + 2 x
1 - C@1D C@2D2 ,
1 - C@1D
1-
F+
1 - C@1D
F>, :y@xD -
x2 + x2
1-
x2 + x2
F-
x2 + x2
1-
JacobiSNB
In[11]:=
1 - C@1D
1 - C@1D C@2D2 ,
1 - C@1D JacobiSNB
1 - C@1D
1 - C@1D + 2 x C@2D + 2 x
1 - C@1D C@2D2 ,
1-
1 - C@1D
1+
1 - C@1D
F>>
sol =
DSolve@8y ''@xD 2 == y@xD ^ 3 - y@xD, y@0D == 0, y '@InfinityD == 0<, y@xD, xD
Solve::ifun :
Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for
complete solution information.
DSolve::bvlim :
For some branches of the general solution, unable to compute the limit at the given points.
Some of the solutions may be lost.
DSolve::bvlim :
For some branches of the general solution, unable to compute the limit at the given points.
Some of the solutions may be lost.
x2 F>>
In[12]:=
85
Out[12]=
0.4
0.2
-2
-1
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]=
x<0
0x1
1 + x2 True
In[4]:=
sol = DSolve@eqn, y, xD
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]=
2.5
2.0
1.5
-3
-2
-1
Out[7]= ::y@xD
-x
In[8]:=
x1
x2
- -
>>
True
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, InfinityL 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, InfinityL is y@2D 2 (given by the final value for the solution over the first interval).
In[9]:=
In[10]:=
t2
3-
t
2
F>>
True
t
Out[10]= 99y FunctionA8t<, E==
In[11]:=
3-
t
2
F>>
eqn = 8y ''@tD + y@tD Piecewise@88- 1, t < 0<, 81, t < 1<, 8Sin@tD, t < 2<<D,
y@0D 1, y '@0D 1<;
In[13]:=
-1 + 2 Cos@tD + Sin@tD
1 + Sin@tD
t
0<
1<
4 ICos@1D2 +Sin@1D2 M
2
True
4 ICos@2D2 +Sin@2D2 M
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
6 ICos@1D2 +Sin@1D2 M
13
J3 3
56
13
33
3
1
356 AiryBiPrime@-1D Cos@1D GammaB F Sin@xD - 3 313 AiryAi@-1D GammaB F Sin@1D Sin@xD +
1
1
4 323
-1-x
2x
J-3 AiryAi@1D - 3
3 AiryAiPrime@1D - 3
3 2 x AiryBi@1D F>>
-1 <
2x
AiryAi@1D +
AiryAiPrime@1D +
3 2 AiryBiPrime@1D +
True
2
3 AiryBi@1D +
1
3 2 x AiryBiPrime@1DN GammaB F
3
89
90
Out[1]= ::y@xD
+ -5 x C@1D>>
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
Out[2]= :y@xD
+ -5 x C@1D>
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 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]:=
+ -5 x C@1DF>>
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
Out[7]= :y FunctionB8x<,
+ -5 x C@1DF>
5
In[8]:=
Out[8]=
y@xD . m
1
+ -5 x C@1D
5
In[9]:=
y '@xD . m
-5 x
C@1D
Out[9]= -5
In[10]:=
Out[10]=
y@1D . m
1
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
Out[12]= -
2
3
2
3
92
In[13]:=
Out[13]=
y@xD . sol@@2DD
2
y@xD . sol
2
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
y FunctionB8t<,
z FunctionB8t<,
1
3
1
3
1
-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
-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
-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>>
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]= :
1
3
1
3
1
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
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]:=
2
3
Out[21]= SolveBRootSumB-1 + 1 + 1 &,
Log@-1 + y@xDD
2 1 + 3 12
sol@@1DD
2
3
Out[22]= RootSumB-1 + 1 + 1 &,
Log@-1 + y@xDD
2 1 + 3 12
&F -x + C@1D
94
-2 C@1D + 12 F -
InverseFunctionBC@1D LogB1 +
2
FunctionB8x<, InverseFunctionB-C@1D LogB1 +
-2 C@1D + 12 F +
-2 C@1D + 12 F -
2
In[25]:=
-2 C@1D + y@xD2 F -
y@xD
eqn = y '@xD x;
In[2]:=
sol = DSolve@eqn, y, xD
x2
2
In[3]:=
eqn . sol
Out[3]= 8True<
+ C@1DF>>
95
In this example, the equation and an initial condition are verified by substitution.
In[4]:=
In[5]:=
sol = DSolve@eqn, y, xD
I2 + x2 MF>>
2
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]:=
sol = DSolve@eqn, y, xD
+ -3 x C@1D + -2 x C@2DF>>
eqn . sol
-3 x
C@1D + 4 -2 x C@2D + 5 I-3 -3 x C@1D - 2 -2 x C@2DM + 6
Out[9]= :9
Simplify@eqn . solD
Out[10]= 8True<
In[12]:=
3
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]:=
sol = DSolve@eqn, y, xD
In[16]:=
x F C@1D + 2 BesselKB0, 2
x F C@2DF>>
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]:=
Clear@a, y, x, rD
In[18]:=
In[19]:=
sol = DSolve@eqn 0, y, xD
a x4
238
Ix4 M
38
C@1D HypergeometricUB
-1+3
8
3
4
, -
1
2
a x4 F
+
x32
a x4
238
Ix4 M
38
C@2D LaguerreLB-
-1+3
8
a
a
, - , -
a x4 F
F>>
x32
In[20]:=
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]:=
Out[21]= 80<
97
r := RandomComplex@D
In[23]:=
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]:=
sol = DSolve@eqn 0, y, xD
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.
InverseFunction::ifun : Inverse functions are being used. Values may be lost for multivalued inverses.
General::stop : Further output of InverseFunction::ifun will be suppressed during this calculation.
Solve::tdep :
The equations appear to involve the variables to be solved for in an essentially non-algebraic way.
-x AiryAiBx2 -
Out[25]= SolveB
-x AiryBiBx2 In[26]:=
1
y@xD
1
y@xD
F + AiryAiPrimeBx2 F + AiryBiPrimeBx2 -
1
y@xD
1
y@xD
F
+ C@1D 0, y@xDF
F
sol@@1DD
-x AiryAiBx2 -
Out[26]=
-x AiryBiBx2 -
1
y@xD
1
y@xD
F + AiryAiPrimeBx2 F + AiryBiPrimeBx2 -
1
y@xD
1
y@xD
F
+ C@1D 0
F
2
Out[27]= 99y @xD -y@xD H2 x + y@xDL==
98
x2
2
C@1D +
x2
1 + 2 ErfiB
10
- xF +
1 - 2 ErfiB
+ 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]:=
BesselJB0, 16
-x4 F - 4 BesselJB0, 16
10
15
20
25
30
Out[4]= -2
-4
-6
This nonlinear equation has two solutions that can be plotted on the same graph.
-x4 F +
99
This nonlinear equation has two solutions that can be plotted on the same graph.
In[5]:=
1 - x2 + 2 x32
:y FunctionB8x<,
5
-x I-1 + x2 M +
1 - x2 - 2 x32
1 - x2
-x I-1 + x2 M -
1 - x2
1 - x2
1-x
In[6]:=
5
2
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
2 2
Out[7]= SolveB-5 x
K-5 x+
1
y@xD
, y@xDF
-5 x+
2 C@1D +
2 p ErfiB
1
y@xD
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
K-5 x+ O
y
-5 x+
+5
2 p x ErfiB
2
Out[8]= -
10 x
1
y
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
-3 313 AiryAiPrimeB -
13
2
AiryAiPrimeB -
3
2
y FunctionB8t<,
13
1
3
tF GammaB F + 356 AiryBiPrimeB 3
2
2
tF GammaB F + 3 H-1L13 223
3
1
3
GammaB F + 6 323 AiryAiB 3
2
In[11]:=
13
13
13
1
tF GammaB F + 9 H-1L13 223
3
3 AiryBiPrimeB -
1
tF GammaB F - H-1L23 213
3
2
3
tF GammaB F + 6 316 AiryBiB 3
2
13
3
2
2
tF GammaB F F,
3
3 AiryBiB -
Out[11]=
-2
-4
10
13
2
13
2
tF GammaB F F>>
3
tF
101
The ParametricPlot function can be used to trace the solution curve 8x@tD, y@tD< in the plane.
In[12]:=
Out[12]=
-4
-2
-1
-2
-3
96
62
y FunctionB8t<,
tF +
5
3
15 SinB
tF UnitStep@-tD F,
5
-430 - 90 t + 81 t2 + 526 CosB
480
tF + 62
15 SinB
tF UnitStep@-tD F>>
In[14]:=
Out[14]=
1
-2
-1
3
5
tF -
102
x
Out[15]= ::u FunctionB8x, y<, + C@1DB
I-x3 + 3 yMFF>>
Here is a plot of the solution surface for a particular choice of the arbitrary function C@1D.
In[16]:=
Out[16]=
-x
Out[1]= 99y@xD 1 + C@1D==
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]:=
-x
Out[2]= 99y@xD 1 + P@1D==
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
In[4]:=
In[5]:=
parameter@indexset@@1DDD
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]:=
F>>
k4
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]=
10
-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]:=
sol = DSolve@eqn 0, y, xD
1
2+a
H2 + aL
1+
1
2+a
2 I2+aM
1-
2+a
a
2
2+a
BesselIB
c x
1+
1
2+a
F C@2D GammaB1 +
2+a
2+a
H2 + aL
F+
2+a
2+a
-2 - a
c x
F C@1D GammaB
2+a
2+a
FF>>
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]:=
C@2D Sinh@2 xD
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]:=
2 + a x2
F>>
2a
1
a
I2 k + x2 MF>>
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]:=
exactpi = Pi;
Precision@exactpiD
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]:=
3. t
C@1DE==
Out[15]= 99x FunctionA8t<,
In[16]:=
3.00000000000000000000000000000000000000 t
C@1DE==
Out[16]= 99x FunctionA8t<,
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]:=
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]:=
0.0001 t
==
Out[23]= 99x@tD 3.07
108
Out[24]= ::x@tD
>>
100
-x
Out[1]= 99y FunctionA8x<, 1 + C@1DE==
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]:=
sol = DSolve@eqns, y, xD
-x
3
x
Out[3]= 99y FunctionA8x<, I4 + ME==
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]:=
x + C@1D F>>
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]:=
I4 - 4 x + x2 MF>, :y FunctionB8x<,
4
In[11]:=
I4 + 4 x + x2 MF>>
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]:=
- 2 y + y
F>>
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