Transcript ODE`s

Ordinary Differential Equations
A differential equation defines a relationship
between an unknown function and one or
more of its derivatives
Physical problems using differential
equations



electrical circuits
heat transfer
motion
Ordinary Differential Equations
The derivatives are of the dependent
variable with respect to the independent
variable
First order differential equation with y as
the dependent variable and x as the
independent variable would be:
dy
 f  x, y 
dx
Ordinary Differential Equations
The analytical solution of ordinary
differential equation as well as partial
differential equations is called the
“closed form solution”
This solution requires that the
constants of integration be evaluated
using prescribed values of the
independent variable(s).
Ordinary Differential Equations
At best, only a few differential
equations can be solved analytically in
a closed form.
Solutions of most practical engineering
problems involving differential
equations require the use of numerical
methods.
One Step Methods
Focus is on solving ODE in the form
dy
= f (x, y )
dx
y i+ 1 = y i + f h
h
y
yi
x
This is the same as saying:
new value = old value + (slope) x (step size)
One Step Methods
Focus is on solving ODE in the form
dy
= f (x, y )
dx
y i+ 1 = y i + f h
h
y
yi
slope = f
x
This is the same as saying:
new value = old value + (slope) x (step size)
Euler’s Method
The first derivative provides a direct
estimate of the slope at xi
The equation is applied iteratively, or
one step at a time, over small distance
in order to reduce the error
Hence this is often referred to as
Euler’s One-Step Method
EXAMPLE
For the initial condition y(1)=1, determine y
for h = 0.1 analytically and using Euler’s
method given:
dy
2
= 4x
dx
dy
2
 4x
dx
I.C. y  1 at x  1
4 3
y x C
3
1
C
3
4 3 1
y x 
3
3
y 1.1  1.44133
dy
2
 4x
dx
yi 1  yi  fh
y 1.1  y 1  4 1   0.1  1.4


2
dy
 4x 2
dx
y i 1  yi  fh
2

y 1.1  y 1  4 1   0.1  1.4


Note :
y 1.1  y 1   4 1   0.1


2
I.C.
dy/dx
step size
dy
2
 4x
dx
yi 1  yi  fh
y 1.1  y 1  4 1   0.1  1.4


2
Recall the analytical solution was 1.4413
If we instead reduced the step size to to 0.05 and
apply Euler’s twice
If we instead reduced the step size to to 0.05 and
apply Euler’s twice:
2

y(1.05)  y(1)  4 1  1.05  1.00  1  0.2  1.2


2

y 1.1  y 1.05  4 1.05  1.1  1.05  1.4205


Recall the analytical solution was 1.4413
Error Analysis of Euler’s
Method
Truncation error - caused by the nature of
the techniques employed to approximate
values of y



local truncation error (from Taylor Series)
propagated truncation error
sum of the two = global truncation error
Round off error - caused by the limited
number of significant digits that can be
retained by a computer or calculator
Modification of Euler’s
Methods
A fundamental error in Euler’s method is that
the derivative at the beginning of the interval
is assumed to apply across the entire interval
Two simple modifications will be
demonstrated
These modification actually belong to a larger
class of solution techniques called RungeKutta which we will explore later.
Heun’s Method
Consider a Taylor expansion with 3 terms:
Approximate f’ as a simple forward difference
f '  x i , yi 
f  x i 1, yi 1   f  x i , yi 

h
Heun’s Method
Substituting into the expansion
yi 1  yi  fi
2
f

f
h
 i 1 i 
 fi 1  fi 
h
 yi  

h
 h  2
 2 
Heun’s Method
Determine the derivatives for the interval @


the initial point
end point (based on Euler step from initial point)
Use the average to obtain an improved
estimate of the slope for the entire interval
We can think of the Euler step as a “test” step
y
Take the slope at xi
Project to get f(xi+1 )
based on the step size h
h
xi
xi+1
y
h
xi
xi+1
y
Now determine the slope
at xi+1
xi
xi+1
y
xi
xi+1
Take the average of these
two slopes
y
xi
xi+1
y
Use this “average” slope
to predict yi+1
xi
xi+1
{
f  xi , yi   f xi 1 , yi 1 
yi 1  yi 
h
2
y
Use this “average” slope
to predict yi+1
xi
xi+1
{
yi 1  yi 
f  xi , yi   f xi 1 , yi 1 
h
2
y
f  xi , yi   f xi 1 , yi 1 
yi 1  yi 
h
2
y
xi
xi+1
xi
xi+1
x
f  xi , yi   f xi 1 , yi 1 
yi 1  yi 
h
2
y
yi 1  yi  fh
xi
xi+1
x