Вы находитесь на странице: 1из 8

Equations which are composed of an unknown function and its derivatives are called differential equations.

Ordinary Differential Equations

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

v- dependent variable t- independent variable

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.

An approximation to this is:

y ( x0 )

y ( x0 + h ) y ( x0 ) h

Forward Difference Formula

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

A sequence can be written as:

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.)

Leonhard Euler 1707 - 1783

Greg Kelly, Hanford High School, Richland, Washington

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

yi+1, Predicted value

Figure 2. General graphical interpretation of Eulers method

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:

h is a small number by which x is incremented. Value of y at

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

Find the value of y(0.8).

Let h = 0.1

Given:

f ( xn , yn ) = y(at x = xn ) = yn xn

Based on the sequence generated by Eulers method we can write:

y ( at x = x0 ) = y0 = 0.5
where

Our starting point.

x0 = 0

y1 y0 + hf ( x0 , y0 )
f ( x0 , y0 ) = y0 x0 = 0.5 0 = 0.5

x1 = x0 + h = 0 + 0.1 = 0.1 x2 = x0 + 2h = 0 + 2 0.1 = 0.2 x3 = x0 + 3h = 0 + 3 0.1 = 0.3

y1 0.5 + 0.1 0.5 = 0.55

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

y2 0.55 + 0.1 0.45 = 0.595

y3 0.595 + 0.1 0.395 = 0.6345


Approximate value of y at x = x3 is 0.6345.

Therefore, we can write that

y( 0.1) = y1 0.55 y( 0.2 ) = y2 0.595 y( 0.3) = y3 0.6345 . . y( 0.8) = y8 0.728205

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

are the Eulers method.

The true error in the approximation is given by


Et = f ( xi , yi ) 2 f ( xi , yi ) 3 h + h + ... 2! 3!

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

Вам также может понравиться