Академический Документы
Профессиональный Документы
Культура Документы
Differential equations play a fundamental role in engineering (and also many real life problems) because many physical phenomena are best formulated mathematically in terms of their rate of change.
dv c =g v dt m
When a function involves one dependent variable, the equation is called an ordinary differential equation (or ODE). A partial differential equation (or PDE) involves two or more independent variables. Differential equations are also classified as to their order.
A first order equation includes a first derivative as its highest derivative. A second order equation includes a second derivative.
Higher order equations can be reduced to a system of first order equations, by redefining a variable.
3 4
Some revisions on
NUMERICAL DIFFERENTIATION
The derivative of y(x) at x0 is:
y ( x 0 )
y ( x0 + h ) y ( x0 ) h
y ( x0 ) = lim
h 0
y ( x0 + h ) y ( x0 ) h
hy ( x0 ) y ( x0 + h ) y( x0 )
y( x0 ) + hy ( x0 ) y ( x0 + h )
y ( x0 + h ) y( x0 ) + hy ( x0 )
for small values of h.
y ( x0 )
y ( x0 + h ) y ( x0 ) h
Provided h is small.
y ( x0 + h ) y( x0 ) + hy ( x0 )
y ( x0 + h ) y( x0 ) + hy ( x0 )
y ( x0 + h )
y ( x0 )
The value of a function at
x0 + h
y ( x0 )
x0
hy ( x0 )
can be approximated if we know its value and its slope at an earlier point, provided h is small.
x0
y1 y0 + hy0
y2 y1 + hy1
yn +1 yn + hyn
In an initial value problem, and often written as: Therefore,
Eulers Method
Leonhard Euler made a huge number of contributions to mathematics, almost half after he was totally blind.
yn
is given
f (x n , y n )
yn+1 yn + hf ( xn , yn )
(When this portrait was made he had already lost most of the sight in his right eye.)
There are many differential equations that can not be solved but we can still find an approximate solution.
dy = 2x dx
n
y0 = 1
dy dx
dx = 0.5
5 4 3 2 1
xn
yn
1 1
dy
yn +1
0
We will practice with an easy one that can be solved.
0
1 2
1 1.5 2.5
1 2
.5
.5
1
1 1.5
dy = 2x dx
Initial value:
y0 = 1
dy dx = dy dx
yn + dy = yn+1
0 1 2
3
dy = 2x dx n
y0 = 1
dy dx
dx = 0.5 dy
5 4 3 2 1
dy = 2x dx
( 0,1)
dx = 0.5
5 4 3 2 1
xn
0 .5
yn
1 1
yn+1
1 1.5 2.5 4.0
Exact Solution:
0 1 2
0
1 2
0 .5
1
dy = 2 x dx y = x2 + C
1= 0+C
y = x2 + 1
1 2
3
1 1.5
3 1.5 2.5
4 2.0 4.0
dy dx = dy dx
1.5
yn + dy = yn+1
0 0 1 2
3
5
This is called Eulers Method.
4
It is more accurate if a smaller value is used for
dx.
3
yi +1 = yi + f ( xi , yi )h
True Value
It gets less accurate as you move away from the initial value.
2 1
h = xi+1 xi
yi h Step size xi xi+1
16
and,
In general Eulers method is given as:
f ( xn , yn ) = y( xn )
is the first derivative of y at x = x
n
yn+1 yn + hf ( xn , yn )
where:
yn = y( xn )
yn+1 = y( xn+1 )
x = xn
= xn+1
Value of y at x
x1 x2 x3 xn
= = = =
x0 + h x1 + h = x 0 + 2 h x2 + h = x0 + 3h x 0 + nh
So what are we doing in Eulers method ??? We are approximating the value of the function y at x = xn+1 based on the information that we obtained at the previous point, x = xn . The previous information are: i) The value of y at x = xn , ii) The value of the first derivative of y at x = xn.
Example:
Consider the following initial value problem.
y = y x
, y( 0) = 0.5
Let h = 0.1
Given:
f ( xn , yn ) = y(at x = xn ) = yn xn
y ( at x = x0 ) = y0 = 0.5
where
x0 = 0
y1 y0 + hf ( x0 , y0 )
f ( x0 , y0 ) = y0 x0 = 0.5 0 = 0.5
y2 y1 + hf ( x1 , y1 )
y3 y2 + hf ( x2 , y2 )
x1 = x0 + h = 0 + 0.1 = 0.1
f ( x1 , y1 ) = y1 x1 = 0.55 0.1 = 0.45
x2 = x0 + 2 h = 0 + 2 0.1 = 0.2
f ( x2 , y2 ) = y2 x2 = 0.595 0.2 = 0.395
It can be seen that Eulers method has large errors. This can be illustrated using Taylor series.
yi +1 = yi + dy dx
( xi +1 xi ) +
xi , yi
1 d2 y 2! dx 2
( xi +1 xi )
xi , yi
1 d3y 3! dx 3
( xi +1 xi )
xi , yi
+ ...
yi +1 = yi + f ( xi , yi ) ( xi +1 xi ) + +
1 2 f '( xi , yi ) ( xi +1 xi ) 2!
1 3 f ''( xi , yi ) ( xi +1 xi ) + ... 3!
As you can see the first two terms of the Taylor series
y i+1 = yi + f ( xi , yi )h
Et h 2
26
Error Analysis for Eulers Method/ Numerical solutions of ODEs involves two types of error:
Truncation error
Local truncation error
The Taylor series provides a means of quantifying the error in Eulers method. However;
The Taylor series provides only an estimate of the local truncation error-that is, the error created during a single step of the method. In actual problems, the functions are more complicated than simple polynomials. Consequently, the derivatives needed to evaluate the Taylor series expansion would not always be easy to obtain.
f ( xi , yi ) 2 h 2! Ea = O ( h 2 ) Ea =
Propagated truncation error
In conclusion,
the error can be reduced by reducing the step size If the solution to the differential equation is linear, the method will provide error free predictions as for a straight line the 2nd derivative would be zero.
27 28
The sum of the two is the total or global truncation error Round-off errors
Figure 25.4
A fundamental source of error in Eulers method is that the derivative at the beginning of the interval is assumed to apply across the entire interval. Two simple modifications are available to circumvent this shortcoming:
Heuns Method The Midpoint (or Improved Polygon) Method
29
30