WOLFRAM|DEMONSTRATIONS PROJECT

Graphic Solution of a Second-Order Differential Equation

​
(f,g)
1
initial values
x
1
0.1
y
1
0.3
z
1
1.4
step size
h
0.2
number of points
n
3
graphics / table
show 'exact' solution
show explanation
′
y
z
′
z

2
x
(-y)-z
This Demonstration shows the Euler–Cauchy method for approximating the solution of an initial value problem with a second-order differential equation. An example of such an equation is
y''+y'+
2
x
y=0
, with derivatives from now on always taken with respect to
x
. This equation can be written as a pair of first-order equations,
y'=z
,
z'=-
2
x
y+z
.
More generally, the method to be described works for any system of two first-order differential equations
y'=f(x,y,z)
,
z'=g(x,y,z)
with initial conditions
y(
x
1
)=
y
1
,
z(
x
1
)=
z
1
. The particular kinds of systems used as examples here,
y''=g(x,y,y')
, reduce to that general type by introducing
z=y'
to get the system
y'=z
,
z'=g(x,y,z)
.
The method consists of simultaneously calculating approximations of
y(x)
(cyan) and
z(x)
(green):
y
i+1
=
y
i
+hy'(
x
i
)=
y
i
+hf(
x
i
,
y
i
,
z
i
)
,
z
i+1
=
z
i
+hz'(
x
i
)=
z
i
+hg(
x
i
,
y
i
,
z
i
)
,
i=1,….n-1
.
The pairs
(
x
i
,
y
i
)
are the coordinates of points
P
1
,
P
2
, …,
P
n
that form the so-called Euler's polygonal line that approximates the graph of the function
y(x)
. In the same way, the pairs
(
x
i
,
z
i
)
are the coordinates of points
T
1
,
T
2
, …,
T
n
that form Euler's polygonal line, which approximates the graph of the function
z(x)
.
The Euler method is the most basic approximation method. The Demonstration compares it with more advanced methods given by the built-in Mathematica function NDSolve.