Professional Documents
Culture Documents
Newton-Raphson Method Newton-Raphson method-MATLAB Implementation Other topics to be covered on the whiteboard Homework 6
Newton-Raphson Method
1 Newton-Raphson Method
4 Homework 6
Newton-Raphson Method Newton-Raphson method-MATLAB Implementation Other topics to be covered on the whiteboard Homework 6
Polynomial approximation and interpolation (lec. 7, 8) Curve tting (regression, spline interpolation) (lec. 7, 8) Simultaneous linear equations (lec. 9) Numerical integration (lec 10) Ordinary differential equations (lec 11)
Newton-Raphson Method Newton-Raphson method-MATLAB Implementation Other topics to be covered on the whiteboard Homework 6
Your tangent lines in this case will eventually pass by the zero of the function.
Newton-Raphson Method-Formula
Newton-Raphson Method Newton-Raphson method-MATLAB Implementation Other topics to be covered on the whiteboard Homework 6
f (xi )(xi xi +1 ) = f (xi ) f (xi )xi f (xi )xi +1 = f (xi ) f (xi )xi f (x ) = f (xi )xi +1 xi +1 = f (xi )xi f (xi ) f (xi ) f (x ) f (xi )
5
= xi
Newton-Raphson Method-Algorithm
Newton-Raphson Method
1 Calculate f (x ) symbolically. 2 Choose an initial guess x0 . 3 Compute x1 = x0 f (x0 ) , and in general xi +1 = xi f (xi ) 0 i Compute the (Absolute) relative approximation error x0 Rapprox = | x1x | 1 If Rapprox < tol , where tol is some pre-specied
tolerance, then stop the algorithm, x1 is our estimated root. Otherwise, go back to step 3.
f (x ) f (x )
Newton-Raphson Method-example
Example
Newton-Raphson Method Newton-Raphson method-MATLAB Implementation Other topics to be covered on the whiteboard
xi +1 = xi xi +1 = xi
Homework 6
Iterating this formula from initial guess x0 = 0.6 gives x1 = 2(0.6)3 + 1 3(0.6)2 + 1
0.2731
Newton-Raphson Method-FPI
Newton-Raphson Method
Use your FPI function to solve the function cos(x ) = x , with starting point x0 = 1 To solve this equation, you may introduce a function f (x ) = x cos(x ). How many iterations are needed for covergence to 6 decimals? Apply this function in the Newton Raphsons method and use your FPI function to solve the equation again. How many iterations are needed for convergence?
Newton-Raphson Method Newton-Raphson method-MATLAB Implementation Other topics to be covered on the whiteboard Homework 6
Assume that {pn } n=0 converges to p and set En = p pn for n 0. If two positive constants A = 0 and R > 0 exist, and
If R = 1, the convergence of {pn } n=0 is called linear. If R = 2, the convergence of {pn } n=0 is called quadratic.
Let f be twice continuously differentiable and f (r ) = 0. If f (r ) = 0, then Newtons Method is locally and quadratically convergent to r . The error ei at step i satises lim ei +1 ei2
Newton-Raphson Method Newton-Raphson method-MATLAB Implementation Other topics to be covered on the whiteboard Homework 6
=M
where M=
f (r ) 2f (r )
If Newton-Raphson method converges-does it always obey quadratic convergence? Exercise: compute M in the previous exercise where f (x ) = x 3 + x 1 = 0.
10
function x =newton1(f,df,x0,tol1,tol2, iterNr) %Input - f is the function in f(x) =0 Newton-Raphson % - df is the derivative of f method-MATLAB Implementation % - x0 is the initial guess % - tol1 is the tolerance for xo Other topics to be covered on the % - tol2 is the tolerance for the function values y whiteboard % - iterNr is the maximum number of iterations Homework 6 %Output - x is the sequence of estimates x(1) =x0; for k=2: iterNr x(k)=x(k-1)-f(x(k-1))/df(x(k-1)); err=abs(x(k)-x(k-1)); y=f(x(k)); if (err<tol1)|(abs(y)<tol2),break,end end x=x
Newton-Raphson Method
11
Newton-Raphson Method Newton-Raphson method-MATLAB Implementation Other topics to be covered on the whiteboard Homework 6
12
Newton-Raphson Method
Section 2.4, ex 3, 4 (Mathews page 85), compute by hand (calculator/excel etc), dont use the Matlab function. Plot the error sequence for 20 iterations of the previous exercise. Write a MATLAB Function that takes a function f and a value x0 and returns the approximated derivative f (x0 ) using CDD method. Modify function newton1 so that input df can be dropped.
13
J.H. Mathews, K.D. Fink.(2004). Numerical Methods Using Matlab, 4th edition, Pearson Education Inc. T. Sauer (2014). Numerical Analysis, 2nd edition. Pearson Education.
Newton-Raphson Method Newton-Raphson method-MATLAB Implementation Other topics to be covered on the whiteboard Homework 6
13