Professional Documents
Culture Documents
and Lagrange's formula. Since By Sheperd's Zig-Zag rule any aritrary path from
function values to its highest divided difference to compute the value of f(x) in all
these examples first fuction value and its higher divided differences are been used to
compute f(x).
1. Find f(2) for the data f(0) = 1, f(1) = 3 and f(3) = 55.
x 0 1 3
f 1 3 55
Solution :
xi fi
0 1
2
1 3 8
26
3 55
Now Newton's divided difference formula is
f(x) = f [x0] + (x - x0) f [x0, x1] + (x - x0) (x - x1) f [x0, x1, x2]
f(2) = 1 + (2 - 0) 2 + (2 - 0)(2 - 1) 8
= 21
By Lagrange's formula :
f(2) = 21
xi fi
0 1
13
1 14 -6
1 1
2 15 -2 0
-5 1 0
4 5 2 0
1 1
5 6 6
13
6 19
Now Newton's divided difference formula is
f(x) = f [x0] + (x - x0) f [x0, x1] + (x - x0) (x - x1) f [x0, x1, x2] + (x - x0) (x - x1) (x -
x2)f [x0, x1, x2, x3]
= 10
By Lagrange's formula :
(3 - 1)(3 - 2)(3 - 4)(3 - 5)(3 - 6) (3 - 0)(3 - 2)(3 - 4)(3 - 5)(3 - 6)
f(3) = 1+ 14+
(0 - 1)(0 - 2)(0 - 4)(0 - 5)(0 - 6) (1 - 0)(1 - 2)(1 - 4)(1 - 5)(1 - 6)
f(2) = 10
xi fi
0.1 9.9833
-50.166
0.2 4.9667 166.675
-16.83 -416.68
0.3 3.2836 41.67 833.42
-8.497 -83.32
0.4 2.4339 16.675
-5.162
0.5 1.9177
Now Newton's divided difference formula is
f(x) = f [x0] + (x - x0) f [x0, x1] + (x - x0) (x - x1) f [x0, x1, x2] + (x - x0) (x - x1) (x -
x2)f [x0, x1, x2, x3]
+ (x - x0) (x - x1) (x - x2)(x - x3)f [x0, x1, x2, x3, x4]
(0.25 - 0.1) (0.25 - 0.2) (0.25 - 0.3) -416.68 + (0.25 - 0.1) (0.25 - 0.2) (0.25 - 0.3)(0.25
- 0.4) 833.42
= 3.912
By Lagrange's formula :
f(0.25) =
(.25 - .2)(.25 - .3)(.25 - .4)(.25 - .5) (.25 - .1)(.25 - .3)(.25 - .4)(.25 - .5)
9.9833+ 4.9667 +
(.1 - .2)(.1 - .3)(.1 - .4)(.1 - .5) (.2 - .1)(.2 - .3)(.2 - .4)(.2 - .5)
(.25 - .1)(.25 - .2)(.25 - .4)(.25 - .5) (.25 - .1)(.25 - .2)(.25 - .3)(.25 - .5)
3.2836+ 2.4339 +
(.3 - .1)(.3 - .2)(.3 - .4)(.3 - .5) (.4 - .1)(.4 - .2)(.4 - .3)(.4 - .5)
numerical differentiation
Example 1:
Find y(0.5) if y is the solution of IVP y' = -2x-y, y(0) = -1 using Euler's method
with step length 0.1. Also find the error in the approximation.
Example 2:
Use Eulers method to solve for y[0.1] from y' = x + y + xy, y(0) = 1 with h =
0.01 also estimate how small h would need to obtain four-decimal accuracy.
Solution :
f(x, y) = x + y + xy,
Solve the differential equation y' = x/y, y(0)=1 by Euler's method to get y(1). Use the
step lengthsh = 0.1 and 0.2 and compare the results with the analytical solution (y2 = 1
+ x2)
with h = 0.1
y1 = y0 + h f(x0, y0) = 1.0 + 0.1*0.0/1.0 = 1.00
y2 = y1 + h f(x1, y1) = 1.0 + 0.1*0.1/1.0 = 1.01
y3 = y2 + h f(x2, y2) = 1.01 + 0.1*0.2/1.01 = 1.0298
y4 = y3 + h f(x3, y3) = 1.0298 + 0.1*0.3/1.0298 = 1.0589
y5 = y4 + h f(x4, y4) = 1.0589 + 0.1*0.4/1.0589 = 1.0967
y6 = y5 + h f(x5, y5) = 1.0967 + 0.1*0.5/1.0967 = 1.1423
y7 = y6 + h f(x6, y6) = 1.1423 + 0.1*0.6/1.1423 = 1.1948
y8 = y7 + h f(x7, y7) = 1.1948 + 0.1*0.7/1.1948 = 1.2534
y9 = y8 + h f(x8, y8) = 1.2534 + 0.1*0.8/1.2534 = 1.3172
y10 = y9 + h f(x9, y9) = 1.3172 + 0.1*0.9/1.3172 = 1.3855
with h = 0.2
y1 = y0 + h f(x0, y0) = 1.0 + 0.2*0.0/1.0 = 1.0
y2 = y1 + h f(x1, y1) = 1.0 + 0.2*0.2/1.0 = 1.0400
y3 = y2 + h f(x2, y2) = 1.0400 + 0.2*0.4/1.0400 = 1.1169
y4 = y3 + h f(x3, y3) = 1.1169 + 0.2*0.6/1.1169 = 1.2243
y5 = y4 + h f(x4, y4) = 1.2243 + 0.2*0.8/1.2243 = 1.3550
Numerical Solution
x Analytical solution
h = 0.1 h = 0.2
0.0 1.0 1.0 1.0
0.1 1.0 1.0050
0.2 1.01 1.0 1.0198
0.3 1.0298 1.0440
0.4 1.0589 1.0400 1.0770
0.5 1.0967 1.1180
0.6 1.1423 1.1169 1.1662
0.7 1.1948 1.2207
0.8 1.2534 1.2243 1.2806
0.9 1.3172 1.3454
1.0 1.3855 1.3550 1.4142
Using Euler's method find the approximate solution of y' = (y - x)/(y + x), y(0) =
1.0 at x = 0.1by taking h = 0.02
=1.5079413639743826
Example 5:
Find y(0.8) with h = 0.1 from y' = y - 2x/y, y(0) = 1 using Euler's method
Example 1:
Find y(1.0) accurate upto four decimal places using Modified Euler's method by
solving theIVP y' = -2xy2, y(0) = 1 with step lengh 0.2.
Given
y[0.0] = 1.0
Example 2:
Find y in [0,3] by solving the initial value problem y' = (x - y)/2, y(0) = 1.
Compare solutions for h = 1/2, 1/4 and 1/8.
Given
y[0.0] = 1.0
Given
y[0.0] = 1.0
Given
y[0.0] = 1.0
Example 3:
Find y(0.1) for y' = x - y2, y(0) = 1 correct upto four decimal places.
Solution: f(x, y) = x - y2
Given
y[0.0] = 1.0
Example 1:
Find y(1.0) using RK method of order four by solving the IVP y' = -2xy2, y(0) = 1 with step length 0.2.
Also compre the solution obtained with RK methods of order three and two.
Solution:
Given y' = -2*x*y*y, y[0] = 1.0
(Using RK method of order 4) with step length = 0.2
y[0.20] = 0.9615327483765758
y[0.40] = 0.8620524180696251
y[0.60] = 0.7352783369268004
y[0.80] = 0.6097518261638406
y[1.00] = 0.5000071953135232
Comparison of the solution with RK method of orders two, three and four:
Example 2:
Find y in [0,3] by solving the initial value problem y' = (x - y)/2, y(0) = 1 using RK method of order
four with h = 1/2 and 1/4.
Solution:
Given y' = (x-y)/2, y[0.000] = 1.0
(Using RK method of order 4) with step-length = 0.5
Example 3:
Using RK method of order four find y(0.1) for y' = x - y2, y(0) = 1.
Solution:
Given y' = x-y*y, y[0.00] = 1.0
(Using RK method of order 4) with step-length = 0.1
K1 = -0.10000000149011612
K2 = -0.08525000105425715
K3 = -0.08665669017834754
K4 = -0.07341960110462278
y[0.10] = 0.9137945024900086
Example 4:
Using RK method of order four find y at x = 1.1 and 1.2 by solving y' = x2 + y2 , y(1) = 2.3
Solution:
Given y' = x*x+y*y, y[1.00] = 2.3
(Using RK method of order 4) with step-length = 0.1
K1 = 0.628999987438321
K2 = 0.7938110087671021
K3 = 0.83757991687511
K4 = 1.1054407603556848
y[1.10] = 3.1328703854960227
K1 = 1.102487701987972
K2 = 1.4895197934605002
K3 = 1.6358516854539997
K4 = 2.4180710557439085
y[1.20] = 4.76142067142283