ordinary differential equations - stanford university · ordinary differential equations arvind...
TRANSCRIPT
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Ordinary Differential Equations
Arvind [email protected]
Institute for Computational and Mathematical EngineeringStanford University
September 16, 2010
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Lorenz Attractor
dx
dt= σ(y − x)
dy
dt= x(ρ− z)− y
dz
dt= xy − βz
σ is Prandtl number and ρ is Rayleigh number.
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Quantum mechanics
Time dependent Schrodinger’s equation
i~∂
∂tΨ = HΨ
=
(
−~2
2m∇2 + V (r)
)
Ψ
Time independent Schrodinger’sequation
HΨ = EΨ
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Vampire Population
dv
dt= −av + dvh
dh
dt= nv − dvh
a is the death rate of vampires due to contact withsunlight, crucifixes, garlic and vampire hunters.
a
aJ. Optimization Theory and Applications: Vol. 75, No.3,1992
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
What is an ODE?
In general, an n−th order ODE can be written as
F (x , y , y ′, y ′′, . . . , y (n)) = 0
We shall assume that the differential equations can be solved explicitlyfor y (n) in terms of the remaining qunatities
y (n) = f (x , y , y ′, . . . , y (n−1))
A differential equation is said to be linear if it is linear in y and all itsderivatives. Thus, an n−th order ODE can be written as
Pn[y ] = p0(x)y(n) + · · ·+ pn(x)y = r(x)
If r(x) = 0, it is called homogenous.
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
An Existence Theorem
TheoremLet y0 ∈ B, an open subset of Rn, I ⊂ R an interval containing t0.Suppose F is continuous on I × B and satisfies the following Lipschitzestimate in y:
||F (t, y1)− F (t, y2)|| ≤ L||y1 − y2||
for t ∈ I , yj ∈ B. Then the equation
dy
dt= F (t, y) y(t0) = y0
has a unique solution on some t interval containing t0.
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Separation of Variables
If, the equation
dy
dx= f (x , y) can be written as
dy
dx= g(x)h(y)
then, the ODE is separable. If h(y) 6= 0, then
∫1
h(y)dy =
∫
g(x)dx
is the desired solution, y is either an implicit or explicit function of x ,upto an unknown constant of integration.
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Example
Solvedy
dx= (1 + y2)ex
Solution:
1
1 + y2dy = exdx (1)
∫1
1 + y2dy =
∫
exdx
tan−1(y) = ex + C
As such, this is an implicit solution. Taking tan on both sides
y = tan(ex + C )
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Exact Equations
TheoremIf the functions M(x , y) and N(x , y) along with their partial derivativesMy (x , y) and Nx(x , y) be continuous in the rectangleS : |x − x0| < a, |Y − y0| < b (0 < a, b < ∞). Then the ODE
M(x , y)dx + N(x , y)dy = 0 or M(x , y) + N(x , y)y ′ = 0
is exact iff Mx = Ny
If the ODE is exact the implicit solution is
M + Ny ′ = ux + uyy′ = 0 ⇒ u(x , y) = c
then we must have uxy = My and uyx = Nx . Since My and Nx arecontinuous, we must have that uxy = uyx
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
ProofStart with the equation uX = M. Integrating both sides
u(x , y) =
∫ x
x0
M(s, y)ds + g(y)
We shall obtain g(y) from the other equation uy = N. We have
∂
∂y
∫ x
x0
M(s, y)ds + g ′(y) = N(x , y)
Thus,
g(y) =
∫ y
y0
N(x , t)−
∫ x
x0
M(s, y)ds +
∫ x
x0
M(s, y0)ds + g(y0)
So that the solution is given by
∫ y
y0
N(x , t) +
∫ x
x0
M(s, y0)ds = c
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Example
Solve the ODE
(y + 2xey ) + x(1 + xey )y ′ = 0
SolutionHere, M = y + 2xey and N = x(1 + xey ). We haveMy = Nx = 1+ 2xey , ∀(x , y) ∈ S = R
2. Thus, the given ODE is exact inR
2. Taking (x0, y0) = (0, 0) we have
∫ y
0
(x + x2et)dt +
∫ x
0
2sds = xy + x2ey = c
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Integrating Factors
Consider the following ODE
dy
dx+ p(x)y = r(x)
Set r(x) = 0, to obtain the homogenous solution yh(x)
dyhdx
+ p(x)yh = 0 (2)∫
dyhyh
= −
∫
p(x)dx
⇒ yh = c0exp
(
−
∫
p(x)dx
)
for a well defined constant c0
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Integrating Factors contd.For r(x) 6= 0, try solution of form
yp = u(x)exp
(
−
∫
p(x)dx
)
By chain rule,
du
dx=
{dypdx
+ p(x)yp
}
exp
(∫
p(x)dx
)
(3)
= r(x)exp
(∫
p(x)dx
)
u(x) =
∫
r(x)exp
(∫
p(x)dx
)
dx + C
So that,
yp(x) = exp
(
−
∫
p(x)dx
){∫
r(x)exp
(∫
p(x)dx
)
dx + C
}
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Example
dy
dx−
4
xy = x5ex
I .F . ≡ exp
(
−
∫
p(x)dx
)
(4)
= e4 log(x) = x4
Now try yp = u(x)x−4
du
dx= xex (5)
u = xex − ex
To complete the solution
y = x4 [(x − 1)ex + C ]
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Duhamel’s Principle
Consider the first order linear ODE
dy
dt= a(t)y + b(t) y(0) = y0
where, a(t) and b(t) are continuous real valued functions. Define
A(t) =
∫ t
0
a(s)ds
The above ODE can be written as
eA(t)d
dt
(
e−A(t)y)
= b(t)
which yields
y(t) = eA(t)y0 + eA(t)∫ t
0
e−A(s)b(s)ds
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Linearity of Solutions
Consider the homogenous second-order ODE
p0(x)y′′ + p1(x)y
′ + p2(x)y = 0 (6)
where p0(x)(> 0), p1(x) and p2(x) are continuous in [a, b]. We have
TheoremThere exist two solutions y1(x) and y2(x) of eqn. 6 which are linearlyindependent in [a, b]. Because of linearity, for arbitrary constants c1 andc2,
y(x) = c1y1(x) + c2y2(x)
is also a solution to eqn. 6.
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Linear Independence
Define the Wronskian W (x) as
W (x) =
∣∣∣∣
y1(x) y2(x)y ′
1(x) y ′
2(x)
∣∣∣∣= y1(x)y
′
2(x)− y2(x)y′
1(x)
TheoremTwo solutions y1(x) and y2(x) of eqn. 6 are linearly independent if theWronskian, as defined above, is non-zero for some x0 ∈ [a, b].
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Variation of ParametersSuppose, one solution y1(x) of eqn. 6 is known. Substitutey(x) = u(x)y1(x),
p0(uy1)′′ + p1(uy1)
′ + p2(uy1) = 0 (7)
p0y1u′′ + (2p0y
′
1 + p1y1)u′ + (p0y
′′
1 + p1y′
1 + p2y1)︸ ︷︷ ︸
=0. Why?
= 0
Let v = u′ and let y1 6= 0
p0y1v′ + (2p0y
′
1 + p1y1)v = 0
It can be shown that
v(x) =1
y21 (x)
exp
(
−
∫ x p1(t)
p0(t)dt
)
So that,
y2(x) = y1(x)
∫ x 1
y21 (t)
exp
(
−
∫ t p1(s)
p0(s)ds
)
dt
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
VOP Example
It is easy to verify that y1(x) = x2 is a solution of the differential equation
x2y ′′ − 2xy ′ + 2y = 0 x 6= 0
For the second solution,
y2(x) = y1(x)
∫ x 1
y21 (t)
exp
(
−
∫ t p1(s)
p0(s)ds
)
dt (8)
= x2∫ x 1
t4exp
(
−
∫ t (
−2s
s2
)
ds
)
dt
= x2∫ x 1
t4t2dt
= −x
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Inhomogenous equations
TheoremLet y1(x) and y2(x) be two linearly independent solutions to thehomogenous equation 6. Let yp be a particular solution to the ODE.Then, the general solution to the ODE is given by
y(x) = c1y1(x) + c2y2(x) + yp(x)
Further, yp can be computed as
yp(x) = −y1(x)
∫ x r(t)y2(t)
W (t)dt + y2(x)
∫ x r(t)y1(t)
W (t)dt
where, W (x) is the Wronskian defined before.
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Constant coefficient case
Consider,ay ′′ + by ′ + cy = 0 (9)
We try solutions of the form y = erx . This results in the algebraicquadratic equation known as the characteristic equation.
ar2 + br + c = 0
• Real, distinct roots r1, r2.er1x and er2x are two solutions of eqn. 9 and the general solution is
y(x) = c1er1x + c2e
r2x
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Constant coefficient case contd.
• Repeated, real roots r1 = r2 = r .One solution is, of course, erx . To find the other solution, we usethe method of Variation of Parameters. It is easy to show thaty2 = xerx , so that
y(x) = erx(c1 + c2x)
• Complex, conjugate roots r1 = µ+ iν, r2 = µ− iν Using Euler’sformula e iθ = cos θ + sin θ, we can write the general solution as
y(x) = c1eµx cos νx + c2e
µx sin νx
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Euler-Cauchy equations
x2y ′′ + axy ′ + by = 0 x > 0
Also, known as equidimensional ODE’s. Plugging y = xm, we have
x2m(m − 1)xm−2 + axmxm−1 + bxm = 0
or,m(m − 1) + am + b = 0
Depending on the roots, we have three cases
1. Real, distinct roots, m1,m2 : y(x) = c1xm1 + c2x
m2
2. Real, repeated roots, m1 = m2 = m: y(x) = xm1(c1 + c2 log x)
3. Complex conjugate roots, m1 = µ+ iν,m2 = µ− iν:
y(x) = xµ(c1 cos(ν log x) + x2 sin(ν log x))
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Higher Order Homogenous Constant Coefficient ODE’s
Consider the ODE
a0dny
dtn+ a1
dn−1y
dtn−1+ · · ·+ any = 0
Define,
z1 = y (10)
z2 = z ′1 = y ′
......
zn = z ′n−1 = y (n−1)
z ′n = −a1a0
zn −a2a0
zn−1 · · · −ana0
z1
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
System of ODEs
z1z2...
zn−1
zn
′
=
0 10 1
. . .. . .
0 1− an
a0− an−1
a0. . . − a2
a0− a1
a0
︸ ︷︷ ︸
A
z1z2...
zn−1
zn
︸ ︷︷ ︸
z
Can be written asdz
dt= Az z(t = 0) = z0
which has the solution z(t) = eAtz0
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Exponential of a Matrix
eAt = I+ At +(At)2
2!+
(At)3
3!+ . . .
This series always converges and
(eAs
) (eAt
)= eA(s+t)
(eAt
) (e−At
)= I
If the matrix A is diagonalizable, i.e. A = SΛS−1
eAt = I + SΛS−1t + SΛ2S−1 t2
2!+ SΛ3S−1 t
3
3!+ . . . (11)
= S
(
I + Λt +(Λt)2
2!+
(Λt)3
3!+ . . .
)
S−1
= SeΛtS−1
Otherwise, appeal to Jordan Canonical form.
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Euler’s method
We want to approximate the solution of the equation
y ′(t) = f (t, y(t)) y(t0) = y0
Define the points
t0 = a, ti = a+ ih, i = 1, 2, . . . ,N h =b − a
N
Starting with the differential equation, we replace the derivative with afinite difference approximation
y ′(t) =y(ti+1)− y(ti )
h+O(h)
So, using this approximation we have the forward Euler method whichdefines the approximate solution {yi}
Ni=0
yi+1 = yi + hf (ti , yi )
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Properties
Define the error, ei = y(ti )− yi , i = 1, . . . , n. For the forward Eulermethod we expect
ei = O(h)
and assuming the function is Lipschitz continuous, one can also derivethe following error bound
|ei+1| ≤Mh
2L[eL(ti+1−a) − 1]
where,M = max a ≤ t ≤ b|y ′′(t)|
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
Boundary Value problems
Consider the Poisson’s equation
−u′′(x) = f (x) x ∈ [0, 1] u(0) = u(1) = 0
We start with a central difference approximation to the second derivative.Discretizing the domain into equal intervals with N + 1 points,xi = ih, h = 1/N, i = 0, . . . ,N
u′′(xi ) = −f (xi ) =ui+1 − 2ui + ui−1
h2+O(h2)
Motivation Introduction First-Order ODE’s Second Order ODE’s Miscellaneous
This results in a tridiagonal system of equations
1
h2
2 −1−1 2 −1
. . .. . .
. . .
−1 2
u1u2. . .un
=
f (x1)f (x2). . .
f (xN)
The solution to the problem using Finite Differences
−κu′′ + βu′ = f