You are on page 1of 21

Linear Algebra and Differential Equations

Lecture 6
Approximate Methods of Solution

June 21, 2016

Linear Algebra and Differential EquationsLecture 6ApproximateJune


Methods
21, 2016
of Solution
1 / 18

Graphical Solutions
The first order equation
x 0 = f (t, x)
gives the slope of the solution curve at the point (t, x). We can use this to
find an approximate graphical solution to the IVP
x 0 = f (t, x)

x(t0 ) = x0

First on an x-t plane pick a grid of points. Use the DE to construct a


tangent at each point of the grid. This is called a direction field or a
slope field. To graph the solution, start at the point (t0 , x0 ). Now sketch
the curve by ensuring that the solution curve is tangent at each point of
the grid.

Linear Algebra and Differential EquationsLecture 6ApproximateJune


Methods
21, 2016
of Solution
2 / 18

An Example
The direction field below corresponds to the DE
x0 = t2 x2
Four solutions are shown corresponding to the initial conditions
x(0) = 3, x(0) = 1, x(0) = 0.5, x(0) = 1

Linear Algebra and Differential EquationsLecture 6ApproximateJune


Methods
21, 2016
of Solution
3 / 18

Taylor Series

Given the IVP


x 0 = f (t, x)

x(t0 ) = x0

This is enough information to calculate the Taylor series for x(t) about
t = t0 . Differentiating the DE with respect to t.
x 00 = ft + fx x 0 = ft + f fx

x 00 (t0 ) = ft (t0 , x0 ) + f (yt0 , x0 )fx (t0 , x0 )

So the Taylor series has the form


1
x(t) = x0 + f (t0 , x0 )(t t0 ) + x 00 (t0 )(t t0 )2 + O((t t0 )3 )
2

Linear Algebra and Differential EquationsLecture 6ApproximateJune


Methods
21, 2016
of Solution
4 / 18

Example
Consider the IVP
x0 = t x2

x(0) = 1

We can use this to calculate the Taylor series for x(t) about t = 0.
Plugging into the DE immediately gives x 0 (0) = 1. Differentiating
x 00 = 1 2xx 0

x 00 (0) = 1 2(1)(1) = 3

Differentiating again gives


x 000 = 2x 02 2xx 00

x 000 (0) = 2(1)2 2(1)(3) = 8

So the Taylor series for x(t) is


4
3
x(t) = 1 t + t 2 t 3 + O(t 4 )
2
3
Linear Algebra and Differential EquationsLecture 6ApproximateJune
Methods
21, 2016
of Solution
5 / 18

Picard Iteration
The IVP
x 0 = f (t0 , x0 )

x(t0 ) = x0

can be reexpressed in the form


Z

x = x0 +

f (s, x(s)) ds
t0

The Picard scheme consists of substituting the initial condition into this,
integrating, then substituting the expression back into the equation,
continuing with this until your patience runs out.
Z t
x1 = x0 +
f (s, x0 ) ds
Z

t0
t

f (s, x1 (s)) ds

x2 = x0 +
t0

xn+1 = x0 +

f (s, xn (s)) ds
t0

Linear Algebra and Differential EquationsLecture 6ApproximateJune


Methods
21, 2016
of Solution
6 / 18

Example
x0 = t x2
x(0) = 1
Z t
1
x1 = 1 +
f (s, 1) ds = 1 t + t 2
2
0
Z
x2 = 1 +

Z
f (s, x1 (s)) ds = 1 +



1 2 2
(s 1 s + s ) ) ds
2

3
1
1
1
= 1 t + t2 t3 + t4 t5
2
3
4
20
Z
x3 = 1 +

f (s, x2 (s)) ds
0

3
4
= 1 t + t2 t3
2
3
+a bunch more higher order terms
Linear Algebra and Differential EquationsLecture 6ApproximateJune
Methods
21, 2016
of Solution
7 / 18

Numerical approximation methods


It is usually the case that we cannot solve a DE exactly and we have to
resort to numerical methods. Again express the IVP
x 0 = f (t0 , x0 )
in the form

x(t0 ) = x0

x(t) = x0 +

f (s, x(s)) ds
t0

Now split the interval into N equal pieces and let h =


and x(tn ) = xn , the for each subinterval we have
Z tn+1
xn+1 = xn +
f (s, x(s)) ds

tt0
N , tn

= t0 + nh

tn

The different numerical methods correspond to different ways to


approximate the integral.
Linear Algebra and Differential EquationsLecture 6ApproximateJune
Methods
21, 2016
of Solution
8 / 18

Eulers method

The simplest scheme is Eulers method which assumes f (t, x) is constant


on each subinterval.
xn+1 = xn + hf (tn , xn )
In a more geometric way to view it, on each subinterval, we are
approximating the actual function by a straight line whose slope is
obtained from the DE evaluated at the initial point of the subinterval. One
serious problem is that errors can build up very quickly and the
approximate solution we obtain bares no resemblance to the actual
solution. This can be alleviated by choosing the step size h to be smaller.
This of course requires more calculations.

Linear Algebra and Differential EquationsLecture 6ApproximateJune


Methods
21, 2016
of Solution
9 / 18

Example
Again consider the IVP
x0 = t x2

x(0) = 1

The table below shows the Euler method with step size h = 1 to calculate
x(3) = 2.
t
0
1
2
3

x
1
0
1
2

f (t, x)
-1
1
1

x = hf
-1
1
1

x + x
0
1
2

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
10 / 18

Euler with h=1

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
11 / 18

Euler with h=0.5

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
12 / 18

Euler with h=0.2

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
13 / 18

Modified (Improved) Euler method

If we use the trapezoidal rule to evaluate the integral


h
xn+1 = xn + (f (tn , xn ) + f (tn+1 , xn+1 ))
2
The problem with this is to calculate xn+1 we need to evaluate
f (tn+1 , xn+1 ) the way around this is to use the regular Euler method to
approximate xn+1 . Thus the modified Euler scheme is
h
xn+1 = xn + (f (tn , xn ) + f (tn+1 , xn + hf (tn , xn )))
2

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
14 / 18

Comparison of the accuracy of the methods


The Euler method is first order in the sense that the approximation agrees
with the Taylor series for x(t) up to first order terms
The modified Eler method is second order

h
xn+1 = xn + (f (tn , xn ) + f (tn + h, xn + hf (tn , xn )))
2
h
= xn+1 = xn + (f (tn , xn ) + f (tn , xn ) + h(ft (tn , xn ) + ffx (tn , xn )) + O
2
h2
= xn+1 = xn + hf (tn , xn ) + (ft (tn , xn ) + ffx (tn , xn )) + O(h3 )
2
2
h
= xn + hx 0 (tn , xn ) + x 00 (tn , xn ) + O(h3 )
2

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
15 / 18

Example
Yet again consider the IVP
x0 = t x2

x(0) = 1

The table below shows the modified Euler method with step size h = 1 to
calculate x(3) = 2.09375.
t
0
1
2
3

x
1
1
1.5
2.09375

f (t, x)
-1
0
-0.25

hf
-1
0
-0.25

x
0
1
1.25

f
1
1
1.4375

x + h(f + f)/2
1
1.5
2.09375

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
16 / 18

modified Euler with h=1

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
17 / 18

modified Euler with h=0.5

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
18 / 18

modified Euler with h=0.2

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
19 / 18

Example
For the IVP
x 0 = x + et

x(0) = 2

(a) Find the exact solution


(b) Compare the Taylor series of the exact solution about t = 0 with the
one step Euler and modified Euler solutions.
(a) The equation is linear with solution
x(t) = (t + 2)e t
(b)


h2 h3
x(h) = (h + 2) 1 + h +
+
+
2!
3!
5
= 2 + 3h + 2h2 + h3 + O(h4 )
6
Linear Algebra and Differential EquationsLecture 6Approximate
June
Methods
21, 2016
of Solution
20 / 18

For the Euler method


x(h) = 2 + 3h
For the modified Euler
h
x(h) = 2 + (3 + (2 + 3h + e h ))
2


5
3 2 h
h2 h3
= 2+ h+ h +
1+h+
+
+
2
2
2
2!
3!
1
= 2 + 3h + 2h2 + h3 + O(h4 )
12

Linear Algebra and Differential EquationsLecture 6Approximate


June
Methods
21, 2016
of Solution
21 / 18

You might also like