This document discusses numerical methods for solving differential equations and calculating integrals. It introduces Euler's method, modified Euler's method (Heun's method), Taylor's method of order two, Lagrange interpolation, and Simpson's rule for numerical integration. Euler's method approximates the slope at each step to calculate the next value. Modified Euler's method takes the average of the slopes. Taylor's method uses the slope and second derivative. Lagrange interpolation fits a polynomial through given data points. Simpson's rule approximates the integral of a function using a weighted sum over intervals.
3. RREEMMEEMMBBEERR
NNUUMMEERRIICCAALL DDIIFFFFEERREENNTTIIAATTIIOONN
The derivative of y(x) at xis:
0 ( ) ( + ) -
( ) 0 0
Forward Difference
Formula
lim
h
0 0
y x h y x
y x
® h
¢ =
An approximation to this is:
( ) y ( x + h ) -
y ( x
) y x
0 0
0
for small values of h. h
¢ »
school.edhole.com
4. ( ) ( ) 0 0
¢ »
0
hy¢ ( x ) » y ( x + h ) - y(x )
0 0 0 y x h y(x )
y x
+ -
h
( ) ( ) 0 0 0 y(x ) + hy¢ x » y x + h
( ) ( ) 0 0 0 y x + h » y(x ) + hy¢ x
Provided h is small.
school.edhole.com
6. y ( x0 + h) » y(x0 ) + hy¢ ( x0 )
The value of a function at x + h 0
can be approximated if we know its value
and its slope at an earlier point, 0 x
provided h is small.
A sequence can be written as:
1 0 0 y » y + hy¢
school.edhole.com
7. 1 0 0 y » y + hy¢
2 1 1 y » y + hy¢
n 1 n n y y hy + » + ¢
In an initial value problem, n y¢ is given
and often written as: ( ) n n f x , y
( ) n n n n y » y + hf x , y Therefore, +1
school.edhole.com
8. Euler’s Method
n n ( n n ) y » y + hf x , y +1
( ) n n y = y x Value of y at n x = x
( ) +1 +1 = n n y y x Value of y at +1 = n x x
school.edhole.com
9. ( n n ) ( n ) f x , y = y¢ x
First derivative of y at n x = x
h is a small number by which x is incremented.
x = x + h 1 0
x x h x 2h 2 1 0 = + = +
x x h x 3h 3 2 0 = + = +
x x nh n = + 0
school.edhole.com
10. So what are we doing in Euler’s 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:
The value of y at x = xn
The value of the first derivative of y at x = xn
school.edhole.com
11. n n ( n n ) y » y + hf x , y +1
Consider the following initial value problem.
y¢ = y - x , y(0) = 0.5
Find the value of y(0.8).
Let h = 0.1
school.edhole.com
12. Given:
( n n ) n n n f x , y = y¢(at x = x ) = y - x
0 5 0 0 y( at x = x ) = y = .
where 0 0 x =
Our starting point.
. .
x x h
= + = + =
0 0 1 0 1
. .
x x h
= + = + ´ =
2 0 2 0 1 0 2
x x h
3 0 3 0 1 0 3
1 0
2 0
3 0
. .
= + = + ´ =
school.edhole.com
13. Based on the sequence generated by Euler’s
method we can write:
1 0 ( 0 0 ) y » y + hf x , y
0 5 0 0 5 0 0 0 0 f (x , y ) = y - x = . - = .
0 5 0 1 0 5 0 55 1 y » . + . ´ . = .
school.edhole.com
14. 2 1 ( 1 1 ) y » y + hf x , y
0 0 1 0 1 1 0 x = x + h = + . = .
0 55 0 1 0 45 1 1 1 1 f (x , y ) = y - x = . - . = .
0 55 0 1 0 45 0 595 2 y » . + . ´ . = .
school.edhole.com
15. 3 2 ( 2 2 ) y » y + hf x , y
2 0 2 0 1 0 2 2 0 x = x + h = + ´ . = .
0 595 0 2 0 395 2 2 2 2 f (x , y ) = y - x = . - . = .
0 595 0 1 0 395 0 6345 3 y » . + . ´ . = .
Approximate value of y at x = x3 is 0.6345.
school.edhole.com
16. Therefore, we can write that
y y
( . ) = »
.
0 1 0 55
1
y y
( . ) = »
.
0 2 0 595
2
y y
= »
0 3 0 6345
3
y y
( . ) .
0 8 0 728205
8
.
.
( . ) .
= »
school.edhole.com
17. Modified Euler’s Method (Heun’s Method)
In the Modified Euler’s method an average value
of the slope is used.
{ úû
( ) ( ) }ù
» + é + + + +
, , * 1 2 1 1
êë
1
n n n n n n y y h f x y f x y
Where
*
n+1 y is calculated using the Euler’s method.
( ) n n n n y* » y + hf x , y +1
school.edhole.com
18. ( ) n n n n y* » y + hf x , y +1
*
n+1 y as calculated using the Euler’s
method shown above is used to
obtain the 2nd slope.
( * )
n n f x , y +1 +1
school.edhole.com
19. { úû
( ) ( ) }ù
» + é + + + +
, , * 1 2 1 1
êë
1
n n n n n n y y h f x y f x y
school.edhole.com
20. Consider the previous initial value
problem.
y¢ = y - x , y(0) = 0.5
Find the value of y(0.8).
Again, let h = 0.1
school.edhole.com
21. 0 5 0 0 5 0 0 0 0 f (x , y ) = y - x = . - = .
0 5 0 1 0 5 0 55 1 y* » . + . ´ . = .
0 55 0 1 0 45 1 1 1 1 f (x , y* ) = y* - x = . - . = .
{ úû
( ) ( ) }ù
y y h 1 f x y f x y
» + é , + , * 1 0 2 0 0 1 1
êë
school.edhole.com
22. { úû
( ) ( ) }ù
y y h 1 f x y f x y
» + é , + , * 1 0 2 0 0 1 1
êë
úû
0 . 5 0 . 1 1 . . ù
= . 1 y » + é +
{0 5 0 45} 0 5475
2
êë
school.edhole.com
23. f x y = y - x = -
( , ) . .
0 5475 0 1 1 1 1 1
.
0 4475
=
* . . .
»
y » + ´
0 5475 0 1 0 4475 2
.
0 59225
( , * ) * . .
f x y = y - x = -
0 59225 0 2 2 2 2 2
.
0 39225
=
school.edhole.com
24. { úû
( ) ( ) }ù
y y h 1 f x y f x y
» + é , + , *2 1 2 1 1 2 2
êë
y » + é +
{ }
0 5475 0 1 1 2
. . . .
0 589487
0 4475 0 39225
2
.
»
ù
úû
êë
school.edhole.com
25. Taylor’s Method of Order Two
2
2
2
y x + h = y x + hy¢ x + h y¢¢(x) + R
( ) ( ) ( )
!
Ris called Taylor’s remainder.
2 If h is small then:
2
y(x + h) » y(x) + hy¢(x) + h y¢¢ x
( )
!
2
school.edhole.com
26. 2
y(x + h) » y(x) + hy¢(x) + h y¢¢ x
( )
!
2
Taylor’s method of order two can be written
in the form of the following sequence.
2
y » y + hy¢ + h y¢¢ n + 1
n n 2
n school.edhole.com
27. Solve the following IVP by using Taylor’s method of
order two.
y¢ = - y + x +1 , 0 £ x £ 1 , y(0) = 1
Solution:
y¢¢ = - y¢ +1 = -(- y + x +1) +1 = y - x
2
y » y + hy¢ + h y¢¢ n + 1
n n 2
n school.edhole.com
28. ¢ = - + +1
y y x
¢¢ = -
n n n
y y x
n n n
2
y » y + hy¢ + h y¢¢ n + 1
n n 2
n y » y + h ( - y + x + ) + h ( y - x ) n + n n n 1
2
n n 2
1
school.edhole.com
29. ö
æ
= - + + 2 2
æ
- + ÷ ÷ø
y h h y h h x h n n n + ÷ ÷ø
ç çè
ö
ç çè
1
2 2
1
Let h = 0.1
0 905 0 095 0 1 1 = . + . + . n+ n n y y x
school.edhole.com
30. Results with Taylor’s Method of Order Two
n xn yn+1
0 0.0 1.005
1 0.1 1.019025
2 0.2 1.041218
3 0.3 1.070802
4 0.4 1.107076
school.edhole.com
31. IINNTTEERRPPOOLLAATTIIOONN
Interpolation produces a
function that matches the given
data exactly. The function then
should provide a good
approximation to the data
values at intermediate points.
school.edhole.com
32. Interpolation may also be used
to produce a smooth graph of a
function for which values are
known only at discrete points,
either from measurements or
calculations.
school.edhole.com
33. Given data points
Obtain a function, P(x)
P(x) goes through the data points
Use P(x)
To estimate values at intermediate
points
school.edhole.com
35. Assume that a function goes through three points:
( ( ) ) ( ( ) ) ( ( ) ) 0 0 1 1 2 2 x , y x , x , y x and x , y x .
y(x) » P(x)
( ) ( ) ( ) ( ) ( ) ( ) ( ) 0 0 1 1 2 2 P x = L x y x + L x y x + L x y x
Lagrange Interpolating Polynomial
school.edhole.com
36. ( ) ( ) ( ) ( ) ( ) ( ) ( ) 0 0 1 1 2 2 P x = L x y x + L x y x + L x y x
P x x x x x y x
( - )( -
)
( )( )
( )( )
( )( )
( )( )
( )( )
( ) ( )
x x x x
x x x x y x
x x x x
x x x x y x
x x x x
( )
( )
1 2
0
0 1 0 2
0 2
1
1 0 1 2
0 1
2
2 0 2 1
=
- -
- -
+
- -
- -
+
- -
school.edhole.com
37. y¢(x) » P¢(x)
( ) ( )
P ¢ x x - x - x =
y x
x x x x
x x x y x
x x x x
x x x y x
x x x x
( )
( )
2
1 2
( )( )
2
( )( )
2
( )( )
0
- -
- -
0 1 0 2
0 2
1
1 0 1 2
0 1
2
2 0 2 1
+
- -
- -
+
- -
school.edhole.com
38. NNUUMMEERRIICCAALL IINNTTEEGGRRAATTIIOONN
ò y ( x )
dx = area under the curve f(x) between
b
a
x = a to x = b.
In many cases a mathematical expression for y(x) is
unknown and in some cases even if y(x) is known its
complex form makes it difficult to perform the integration.
school.edhole.com
39. Simpson’s Rule:
x x
x x
ò y x dx » ò P x dx
( ) ( ) 2 2
0 0
x x h x x 2h 1 0 2 0 = + and = +
school.edhole.com
40. P x dx x x x x y x dx
( )( )
( )( )
x x
x x
- -
( ) ( )
- -
( )
( )
ò ò
2 2
=
0 0
2
0
2
0
1 2
0
0 1 0 2
( )( )
0 2
( )( )
( )( )
( )( )
1
1 0 1 2
0 1
2
2 0 2 1
x
x
x
x
x x x x
x - x x -
x y x dx
x x x x
x x x x y x dx
x x x x
+
- -
- -
+
- -
ò
ò
school.edhole.com
41. x x
x x
( ) ( )
( ) ( ) ( )
ò ò
2 2
y x dx P x dx
h y x y x y x
0 0
0 1 2 4
3
»
= éë + + ùû
school.edhole.com
42. Runge-Kutta method uses a
sampling of slopes through an
interval and takes a weighted average
slope to calculate the end point. By
using fundamental theorem as shown
in Figure 1 we can write:
school.edhole.com
46. Integrating both sides of Eqn. (1) we get
ò dy = ò y¢( x) dx (2)
Applying appropriate limits to Eqn.
(2) we get
( ) ( ) x
1
( ) (3) n n òx + - = ¢ +
y x 1 y x y x dx n
n
x h
n ò + + - = ¢
y( x h) y( x ) y ( x)dx (4)
n n x
n
school.edhole.com
47. Let us now concentrate on the right-hand
side of Eqn. (4).
x h
x
n ò ò + +
y ( x) dx P( x) dx (5)
x h
x
n
n
n
¢ »
P(x) can be generated by utilizing Lagrange
Interpolating Polynomial. Assume that the
only information we have about a function,
f(x) is that it goes through three points:
( ( ) ) ( ( ) ) ( ( ) ) 0 0 1 1 2 2 x , y x , x , y x and x , y x .
school.edhole.com
48. P(x) » y(x)
P ( x ) = L ( x ) y ( x ) + L ( x ) y ( x ) + L ( x ) y ( x
) 0 0 1 1 2 2 P ( x ) x - x x -
x y ( x
)
x x x x
x x x x y x
x x x x
x x x x y x
x x x x
( )
( )
( )( )
1 2
( )( )
( )( )
( )( )
( )( )
( )( )
0
0 1 0 2
0 2
1
1 0 1 2
0 1
2
2 0 2 1
=
- -
- -
+
- -
- -
+
- -
school.edhole.com
49. Using Simpson’s Integration,
x x
x x
( ) ( ) 2 2
0 0
ò ò
y x dx »
P x dx
= + ¢ = + ¢
x x h x x h
1 0 2 0 and 2
school.edhole.com
50. P x dx x x x x y x dx
( )( )
( )( )
x x
x x
- -
( ) ( )
- -
( )
( )
ò =
ò
( )( )
( )( )
( )( )
( )( )
ò
ò
2 y ( x ) dx 2
P ( x ) dx h y ( x ) y ( x ) y ( x
) 0 0
...………………….(6)
2 2
0 0
2
0
2
0
1 2
0
0 1 0 2
0 2
1
1 0 1 2
0 1
2
2 0 2 1
x
x
x
x
x x x x
x - x x -
x y x dx
x x x x
x x x x y x dx
x x x x
+
- -
- -
+
- -
0 1 2 4
3
x x
x x
¢
ò » ò = éë + + ùû
school.edhole.com
51. We can apply Simpson’s Integration to Eqn.
(6) with the following substitutions:
x = xn 0 x x h n = + ; 2 ;
h¢ = h/ 2 and the midpoint, 1 2
x x h n = +
ù
ò ¢ » ¢ + ¢æ + + y x dx h y x y x h y x h n n n
é + ¢ + ÷ø
( ) ( ) ( )úû
êë
ö çè
x n
h
x
4
n 6
2
….(7)
school.edhole.com
52. Compared to Euler’s Formula, an average of
six slopes is used in Eqn. (7) instead of just
one slope. Actually, the slope at the midpoint
has a weight of 4. The slope at the midpoint
can be estimated in two ways.
ù
ò ¢ » ¢ + ¢æ + + y x dx h y x y x h y x h y x h n n n n
÷ø
é ÷ø
+ ¢ æ + + ¢ + ( ) ( ) ( )úû
êë
ö çè
ö çè
x n
h
x
2
n 2
2
2
6
ù
y x h y x h é
+ - » y¢ x + y¢æ x + h y x h y x h n n n n n 2
n ö çè
ö çè
( ) ( ) ( ) ( )úû
êë
+ ¢ + ÷ø
+ 2
¢ ÷ø
æ + 2
2
6
ù
y x h y x h é
+ » + y¢ x + y¢æ x + h y x h y x h n n n n n 2
n ö çè
ö çè
( ) ( ) ( ) ( )úû
êë
+ ¢ + ÷ø
+ 2
¢ ÷ø
æ + 2
2
6
school.edhole.com
53. é ¢ + ÷ø
n n 6 n n n n y x y x h y x y x h y x h y x
» + ¢ + ¢æ + +1 2 +1
ö çè
( ) ( ) ( ) ( )úû
The slopes can be estimated in the
following manner:
( n ) ( n n ) y x k f x , y 1 ¢ » =
y x h k f x h y h k n n n
¢æ + 2 2 1
ö çè
÷ø
ö çè
» = æ + ÷ø
,
+ 2 2
ù
êë
+ 2
çè¢ ÷ø
æ + ö 2
2
........... (8)
school.edhole.com
54. y ¢æ x + h k f h h n 3 çè
x y k ö n n
2 2
y ¢ ( x + h ) » k = f ( x + h, y +
hk ) n 4 n n 3 Substituting the estimated slopes into Eqn.
(8) gives the formula for Runge-Kutta
Method of Fourth Order:
÷ø
ö çè
» = æ + ÷ø
,
+ 2 2
y y h k k k k n n = + + + + +
[ ] 1 1 2 3 4 2 2
6
school.edhole.com