Professional Documents
Culture Documents
Objectives
Review week 9 Numerical Differentiation Newtons Forward Difference formula Newtons Backward Difference formula Numerical Integration Trapezoid rule Simpsons one third rule
Newton's Method
Using an initial guess at the root and the slope of f(x), Newton's method uses extrapolation to estimate where f(x) crosses the x axis. This method converges very quickly, but it can diverge if f(x) = 0 is encountered during iterations. (f(x) is the differential of f(x))
March 20, 2012
Algorithm
initialize: x1 = . . . for k = 2, 3, . . . xk = xk-1 - f(xk-1)/f(xk-1) if converged, stop end
Secant Method
The secant method approximates f(x) from the value of f(x) at two previous guesses at the root. It is as fast as the Newton's method but can also fail at f(x)=0.
Algorithm
initialize: x1 = . . ., x2 = . . . for k = 2, 3 .. . xk+1 = xk - f(xk)(xk - xk-1)/(f(xk) - f(xk-1)) If f(xk+1)<0, xk-1 = xk+1, xk=xk else xk-1= xk-1, xk=xk+1 if converged, stop end
March 20, 2012
Numerical Differentiation
We
discuss Newtons forward difference formula in detail. This is suitable for differentiation for the the values towards the beginning of the table
For functions tabulated with constant interval h, E f(x) = f (x+h) E2 f(x)= E (E f(x)) = E f(x+h)=f(x+2h) Like this, Epf(x) = f (x + ph) Again, f(x) = f(x+h) - f(x) Hence f(x+h) = f (x) + f(x) = ( 1 + ) f(x) That is, E f(x) = ( 1 + ) f(x) or simply, E ( 1 + )
Copyright Box Hill Institute
x = x0 + ph,
This is Newtons forward difference formula for differentiation suitable for values given in the table
Copyright Box Hill Institute
f(x)
2.718282
1.2
3.320117
1.4
4.055200
1.6
4.953032
1.8
March 20, 2012
6.049646
Copyright Box Hill Institute
f(x)
2.718282
0.601835
1.2
3.320117
0.735083
1.4
4.055200 0.897832
1.6
4.953032 1.096615
1.8
6.049646
f(x)
2.718282
0.601835
1.2
3.320117
0.735083
0.133248
1.4
4.055200 0.897832
0.162749
1.6
4.953032 1.096615
0.198783
1.8
6.049646
f(x)
2.718282
0.601835
1.2
3.320117
0.133248
0.735083
1.4 4.055200 0.897832 1.6 4.953032 1.096615 1.8
March 20, 2012
0.029501
0.162749 0.036034 0.198783
6.049646
Copyright Box Hill Institute
f(x)
2.718282
0.601835
1.2
3.320117
0.133248
0.735083
1.4 4.055200 0.162749
0.029501
0.006532
0.897832
1.6 4.953032 0.198783
0.036034
1.096615
1.8
March 20, 2012
6.049646
Copyright Box Hill Institute
Example (continued)
To find the differential coefficient for x=1.0 From the table, = 0.601835, 2 = 0.133248 3 = 0.029501, and 4 = 0.006532 Here h = 0.2 The approximate value of the diff coeff = (1/0.2) [ 1/2 2 +1/3 3 1/4 4 ] = 2.717060 The true value is 2.718282
Copyright Box Hill Institute
An example : f(x) = ex
x
1.0
f(x)
2.718282
0.601835
1.2
3.320117
0.133248
0.735083
1.4 4.055200 0.162749
0.029501
0.006532
0.897832
1.6 4.953032 0.198783
0.036034
1.096615
1.8
March 20, 2012
6.049646
Copyright Box Hill Institute
To find the differential coefficient for x=1.8 From the table, = 1.096615, 2 = 0.198783 3 = 0.036033, and 4 = 0.006532 Here h = 0.2 The approximate value of the diff coeff = (1/0.2) [ +1/2 2 +1/3 3 +1/4 4 ] = 6.048252 The true value is 6.049647
Copyright Box Hill Institute
Some remarks
There is a central difference formula for finding differential coefficient when the values are around middle of the table. We did not discuss that. It may be remembered that at times numerical differentiation might be very inaccurate when there are large fluctuations.
Trapezoid Rule
Numerical Integration
Value of a definite integral within its limits is the area under the curve in the limits In numerical integration, the function is approximated by a polynomial, and the area under the polynomial is taken as the value of the integral We study two simple rules (1) Trapezoidal rule and (2) Simpson's one-third rule
Value of integral of f (x) between a and b is the area under the curve between a and b
March 20, 2012
f(x)
f(x)
a0=a
a1
a2 = b
Value of the integral is better approximated by = area of trapezium 1 + area of trapezium 2 = [f(a0) +f(a1)].(a1 a0)+ [f(a1) +f(a2)](a2 a1)
March 20, 2012
If a1=a0 + h , and, a2 =a1+ h= a0 +2h, The approximate area under the curve (when there are two intervals) = h/2 [ f(a0) + f(a1) ] + h/2 [ f(a1) + f(a2) ] = h/2 [ f(a0) + 2 f(a1) + f(a2) ]
An example : f(x) = ex
x
1.0
f(x)
2.718282
1.2
3.320117
1.4
4.055200
1.6
4.953032
1.8
March 20, 2012
6.049646
Copyright Box Hill Institute
Example (continued)
To evaluate the value of integral f(x) = exp(x) between x= 1.0 and 1.8 Suppose we take interval h = 0.4 Then a0 = 1.0, a1 =1.4, a2= 1.8 The value is given by
(0.4/2)[2.718282 + (2) 4.055200 + 6.049646]
= 3.375666
March 20, 2012
This may be compactly written as (h/3)[ ( f(a0) + f (an) ) + 4 (f(a1) + f (a3) + f(a5)+ f(an-1) ) + 2 (f(a2) + f (a4) + f(a6) + .. f(an-2) ) ] Remember that the number of intervals have to be even
An example : f(x) = ex
To evaluate the value of integral f(x) = exp (x) between x= 1.0 and 1.8 Suppose we take interval h = 0.4 Then a0 = 1.0, a1 =1.4, a2= 1.8 The value is given by
= 3.331831
March 20, 2012
Summary
Newtons Forward Difference Formula f/(x)= (1/h) [ 1/2 2 ++1/3 3 1/4 4 +.]
Newtons Backward Difference Formula f/(x)= (1/h) [ +1/2 2+1/3 3 + 1/4 4+..]
Copyright Box Hill Institute
Summary
Trapezoid Rule = (h/2) [ f(a0) + 2 f(a1) + 2f(a2) +. + 2 f(an-1) + f(an)] Simpsons One Third Rule (the number of intervals have to be even) = (h/3)[ ( f(a0) + f (an) ) + 4 (f(a1) + f (a3) + f(a5)+ f(an-1) ) + 2 (f(a2) + f (a4) + f(a6) + .. f(an-2) ) ]
Copyright Box Hill Institute
References
H L Verma and C W Gross : Introduction to Quantitative Methods,John Wiley JB Scarborough : Numerical Mathematical Analysis, Jon Hopkins Hall, New Jersey Gerald W. Recktenwald, Numerical Methods with MATLAB, Implementation and Application, Prentice Hall Murray Spiegel, John Schiller, Alu Srinivasan, Probability and Statistics, Schaums easy Outlines http://mathworld.wolfram.com
Copyright Box Hill Institute