0% found this document useful (0 votes)
93 views23 pages

Euller

This document discusses numerical methods for solving ordinary differential equations, including Euler's method, Heun's method, the midpoint method, and Runge-Kutta methods, explaining how to implement these one-step methods to find approximate solutions for both single equations and systems of equations. It also covers error analysis and sources of error in the numerical solutions.

Uploaded by

listyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views23 pages

Euller

This document discusses numerical methods for solving ordinary differential equations, including Euler's method, Heun's method, the midpoint method, and Runge-Kutta methods, explaining how to implement these one-step methods to find approximate solutions for both single equations and systems of equations. It also covers error analysis and sources of error in the numerical solutions.

Uploaded by

listyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Numerical Solution

of
Ordinary Differential Equations

1
Chapter Objectives
Understanding the meaning of local and global truncation
errors and their relationship to step size for one-step
methods for solving ODEs.
Knowing how to implement the following Runge-Kutta (RK)
methods for a single ODE:
Euler
Heun
Midpoint
Fourth-Order RK
Knowing how to iterate the corrector of Heuns method.
Knowing how to implement the following Runge-Kutta
methods for systems of ODEs:
Euler
Fourth-order RK
Ordinary Differential Equations
Methods described here are for solving differential
equations of the form:
dy
f t, y
dt
The methods in this chapter are all one-step
methods and have the general format:
yi1 yi h
where is called an increment function, and is
used to extrapolate from an old value yi to a new
value yi+1.
Eulers Method
The first derivative
provides a direct
estimate of the slope
at ti: dy
f t i , yi
dt ti
and the Euler method
uses that estimate as
the increment
function:
f t i , yi
yi1 yi f t i , yi h
Leonhard Euler made a
huge number of
contributions to
mathematics, almost half
after he was totally blind.

(When this portrait was


made he had already lost
most of the sight in his right
eye.)

Leonhard Euler 1707 - 1783



Greg Kelly, Hanford High School, Richland, Washington
It was Euler who originated
the following notations:

f x (function notation)

e (base of natural log)

(pi)

i 1

(summation)

y (finite change) Leonhard Euler 1707 - 1783



There are many differential equations that can not be solved.
We can still find an approximate solution.

We will practice with an easy one that can be solved.

dy
2x Initial Value: (0, 1)
dx

But first Suppose we


couldnt solve this
conventionally

f ( x dx) f ( x)
Remember how it all started? f ( x) lim
dx0 dx
Suppose we took the limit out. f ( x dx) f ( x)
How would that change this?
f ( x)
dx
for very small dx values.
Now lets do a little algebra

f ( x) dx f ( x dx) f ( x)

f ( x dx) f ( x) f ( x) dx

Which brings us to
Eulers Method
of
Approximations

f ( x dx) f ( x) f ( x) dx
So if we know f (x ), we have a value for dx ,
and we have an initial value f (a)
Then by Eulers Method:

f (a dx) f (a) f (a) dx


BUT WHAT DOES IT ALL MEAN!?
There are many differential equations that can not be solved.
We can still find an approximate solution.

We will practice with an easy one that can be solved.

dy
2x Initial Value: (0, 1)
dx

But first Suppose we


couldnt solve this
conventionally

dy 5
2 x f (0) 1 dx 0.5
dx
f (a dx) f (a) f (a) dx 4
f (0 0.5) f (0) f (0) 0.5
f (0.5) f (0) f (0) 0.5 3

f (0.5) 1 2

So we have an
approximate coordinate 1
(0.5, 1)
How could we use this to
approximate f (1) ? 0 1 2 3
dy 5
2x y0 1 dx 0.5
dx
dy 4
n xn yn dx dy yn1
0 0 1 0 0 1
3
1 .5 1 1 .5 1.5
2 1 1.5 2 1 2.5 2

1
dy
dx dy yn dy yn1
dx
0 1 2 3
dy 5
2x y0 1 dx 0.5
dx
dy 4
n xn yn dx dy yn1
0 0 1 0 0 1
3
1 .5 1 1 .5 1.5
2 1 1.5 2 1 2.5 2
3 1.5 2.5 3 1.5 4.0
4 2.0 4.0 1
dy
dx dy yn dy yn1
dx
0 1 2 3
dy 5
2x 0,1 dx 0.5
dx
4
Exact Solution:

dy 2 x dx 3

y x2 C
2
1 0C
1
y x 1
2

0 1 2 3
5
This is called Eulers Method.
4
It is more accurate if a smaller
value is used for dx.
3

It gets less accurate as you


move away from the initial 2
value.

0 1 2 3
Error Analysis for Eulers Method
The numerical solution of ODEs involves two types
of error:
Truncation errors, caused by the nature of the techniques
employed
Roundoff errors, caused by the limited numbers of
significant digits that can be retained
The total, or global truncation error can be further
split into:
local truncation error that results from an application
method in question over a single step, and
propagated truncation error that results from the
approximations produced during previous steps.
Error Analysis for Eulers Method
The local truncation error for Eulers method
is O(h2) and proportional to the derivative of
f(t,y) while the global truncation error is O(h).
This means:
The global error can be reduced by decreasing
the step size, and
Eulers method will provide error-free predictions
if the underlying function is linear.
Eulers method is conditionally stable,
depending on the size of h.
Heuns method
To improve the estimate of the slope,
determine two derivatives for the interval:
At the initial point
At the end point

The two derivatives are then averaged to


obtain an improved estimate of the slope
for the entire interval.

Predictor : yi01 yi f ( xi , yi )h
f ( xi , yi ) f ( xi 1 , yi01 )
Corrector : yi 1 yi h
2

18
The Midpoint (or Improved Polygon) Method

Uses Eulers method to predict a


value of y using the slope value at
the midpoint of the interval:

h
yi 1/2 yi f ( xi , yi )
2

yi 1 yi f ( xi 1/ 2 , yi 1/ 2 )h

19
Runge-Kutta Methods
Runge-Kutta (RK) methods achieve the accuracy of a Taylor
series approach without requiring the calculation of higher
derivatives.
For RK methods, the increment function can be generally
written as:
a1k1 a2 k2 an kn
where the as are constants and the ks are
k1 f t i , yi
k2 f t i p1h, yi q11k1h

k3 f t i p2 h, yi q21k1h q22 k2 h

kn f t i pn1h, yi qn1,1k1h qn1,2 k2 h qn1,n1kn1h


where the ps and qs are constants.
Classical Fourth-Order Runge-
Kutta Method
The most popular RK methods are fourth-
order, and the most commonly used form is:
1
yi1 yi k1 2k2 2k3 k4 h
6
where:
k1 f t i , yi

1 1
k2 f t i h, yi k1h
2 2
1 1
k3 f t i h, yi k2 h
2 2
k4 f t i h, yi k3h
Systems of Equations
Many practical problems require the solution of a
system of equations:
dy1
f1 t, y1 , y2 , , yn
dt
dy2
f2 t, y1 , y2 , , yn
dt
dyn
fn t, y1 , y2 , , yn
dt
The solution of such a system requires that n initial
conditions be known at the starting value of t.

Solution Methods
Single-equation methods can be used to
solve systems of ODEs as well; for example,
Eulers method can be used on systems of
equations - the one-step method is applied
for every equation at each step before
proceeding to the next step.
Fourth-order Runge-Kutta methods can also
be used, but care must be taken in
calculating the ks.

You might also like