Sie sind auf Seite 1von 21

1

Schedule
Week Date Topic Classification of Topic
1 9 Feb. 2010
Introduction to
Numerical Methods
and Type of Errors
Measuring errors, Binary representation,
Propagation of errors and Taylor series
2 14 Feb. 2010
Nonlinear Equations Bisection Method
3 21 Feb. 2010
Newton-Raphson Method
4 28 Feb. 2010 Interpolation
Lagrange Interpolation
5 7 March 2010
Newton's Divided Difference Method
6 14 March 2010
Differentiation Newton's Forward and Backward
Divided Difference
7 21 March 2010 Regression
Least squares
8 28 March 2010
Systems of Linear
Equations
Gaussian Jordan
9 11 April 2010
Gaussian Seidel
10 18 April 2010
Integration Composite Trapezoidal and Simpson
Rules
11 25 April 2010
Ordinary Differential
Equations
Euler's Method
12 2 May 2010
Runge-Kutta 2
nd
and4
th
order Method
2
Exact solution to Separable and
Linear differential equations
3
Ordinary differential equations of order one and degree one
1. Separable equations
Example 1
Solve the equation
2
dy x
dx y
= given that (0) 1 y =
solution
By separating the variables of the equation we get
2
y dy xdx =
4
By integration
2
y dy xdx =
} }
then
3 2
3 2
y x
C = +
The general solution of the equation
Now
(0) 1 y =
y=1 at x=0
then
1 0
3 2
C = +
1
3
C =
the solution of the equation is
3 2
1
3 2 3
y x
= +
5
2. Linear equations
Linear equations are on the form
( ) ( )
dy
p x y q x
dx
+ =
Example
2
1
2
dy
y x
dx x
+ =
+
2
1
( )
2
( )
p x
x
q x x
=
+
=
6
How to solve Linear equations
Linear equations are solved by using the following method
Step 1: Calculate the following integrating factor
( ) p x dx
e
}
=
Step 2: The solution is then given by
( ) y q x dx =
}
7
Example 2
Solve the equation
such that y(0)=2 4 4 = y
dx
dy
solution
This equation could be written on the form
4 4 = y
dx
dy
4 ) (
4 ) (
=
=
x q
x p
Then
x
dx dx x p
e e e
4
4 ) (

=
}
=
}
=
8
The solution will be such that
( ) y q x dx =
}
c e dx e y e
x x x
+ =
}
=
4 4 4
4
Let x=0 , y=2 c=3
Then
x
e y
4
3 1+ =
Euler Method
10
Eulers Method

Step size, h
x
y
x
0
,y
0
True value
y
1
, Predicted
value
( ) ( )
0
0 , , y y y x f
dx
dy
= =
Slope
Run
Rise
=
0 1
0 1
x x
y y

=
( )
0 0
, y x f =
( )( )
0 1 0 0 0 1
, x x y x f y y + =
( )h y x f y
0 0 0
, + =
Figure 1 Graphical interpretation of the first step of Eulers method
11
Eulers Method

Step size
h
True Value
y
i+1
, Predicted value
y
i
x
y
x
i
x
i+1
Figure 2. General graphical interpretation of Eulers method
( )h y x f y y
i i i i
,
1
+ =
+
i i
x x h =
+1
12
How to write Ordinary Differential
Equation
Example
( ) 5 0 , 3 . 1 2 = = +

y e y
dx
dy
x
is rewritten as
( ) 5 0 , 2 3 . 1 = =

y y e
dx
dy
x
In this case
( ) y e y x f
x
2 3 . 1 , =

How does one write a first order differential equation in the form of
( ) y x f
dx
dy
, =
13
Example
A ball at 1200K is allowed to cool down in air at an ambient temperature of
300K. Assuming heat is lost only due to radiation, the differential equation for
the temperature of the ball is given by
( ) ( ) K
dt
d
1200 0 , 10 81 10 2067 . 2
8 4 12
= =

u u
u
Find the temperature at
480 = t
seconds using Eulers method. Assume a step size of
240 = h
seconds.
14
Solution
( )
( )
( )
( ) ( )
( )
K
f
h t f
h t f
i i i i
09 . 106
240 5579 . 4 1200
240 10 81 1200 10 2067 . 2 1200
240 1200 , 0 1200
,
,
8 4 12
0 0 0 1
1
=
+ =
+ =
+ =
+ =
+ =

+
u u u
u u u
Step 1:
1
u
is the approximate temperature at 240 240 0
0 1
= + = + = = h t t t
( ) K 09 . 106 240
1
= ~u u
( )
8 4 12
10 81 10 2067 . 2 u =
u

dt
d
( ) ( )
8 4 12
10 81 10 2067 . 2 , u = u

t f
15
Solution Cont
For
09 . 106 , 240 , 1
1 1
= = = u t i
( )
( )
( ) ( )
( )
K
f
h t f
32 . 110
240 017595 . 0 09 . 106
240 10 81 09 . 106 10 2067 . 2 09 . 106
240 09 . 106 , 240 09 . 106
,
8 4 12
1 1 1 2
=
+ =
+ =
+ =
+ =

u u u
Step 2:
2
u
is the approximate temperature at 480 240 240
1 2
= + = + = = h t t t
( ) K 32 . 110 480
2
= ~u u
16
Solution Cont
The exact solution of the ordinary differential equation is given by the
solution of a non-linear equation as
( ) 9282 . 2 10 22067 . 0 00333 . 0 tan 8519 . 1
300
300
ln 92593 . 0
3 1
=
+


t u
u
u
The solution to this nonlinear equation at t=480 seconds is
K 57 . 647 ) 480 ( = u
17
Comparison of Exact and
Numerical Solutions
Figure 3. Comparing exact and Eulers method
0
200
400
600
800
1000
1200
1400
0 100 200 300 400 500
Time, t(sec)
T
e
m
p
e
r
a
t
u
r
e
,

h=240
Exact Solution

(
K
)
Step, h u(480) E
t
|
t
|%
480
240
120
60
30
987.81
110.32
546.77
614.97
632.77
1635.4
537.26
100.80
32.607
14.806
252.54
82.964
15.566
5.0352
2.2864
18
Effect of step size
Table 1. Temperature at 480 seconds as a function of step size, h
K 57 . 647 ) 480 ( = u
(exact)
19
Comparison with exact results
-1500
-1000
-500
0
500
1000
1500
0 100 200 300 400 500
Time, t (sec)
T
e
m
p
e
r
a
t
u
r
e
,
Exact solution
h=120
h=240
h=480

(
K
)
Figure 4. Comparison of Eulers method with exact solution for different step sizes
20
Effects of step size on Eulers
Method
-1200
-800
-400
0
400
800
0 100 200 300 400 500
Step size, h (s)
T
e
m
p
e
r
a
t
u
r
e
,

(
K
)
Figure 5. Effect of step size in Eulers method.
21
Errors in Eulers Method
It can be seen that Eulers method has large errors. This can be illustrated using
Taylor series.
( ) ( ) ( ) ...
! 3
1
! 2
1
3
1
,
3
3
2
1
,
2
2
1
,
1
+ + + + =
+ + + + i i
y x
i i
y x
i i
y x
i i
x x
dx
y d
x x
dx
y d
x x
dx
dy
y y
i i i i
i i
( ) ( ) ( ) ... ) , ( ' '
! 3
1
) , ( '
! 2
1
) , (
3
1
2
1 1 1
+ + + + =
+ + + + i i i i i i i i i i i i i i
x x y x f x x y x f x x y x f y y
As you can see the first two terms of the Taylor series
( )h y x f y y
i i i i
,
1
+ =
+
The true error in the approximation is given by
( ) ( )
...
! 3
,
! 2
,
3 2
+
' '
+
'
= h
y x f
h
y x f
E
i i i i
t
are the Eulers method.
2
h E
t

Das könnte Ihnen auch gefallen