As we know that Newton-Raphson Method is the most widely used of all root-locating formulas. The Newton-Raphson method uses the slope (first derivative) of the function to find the root. That means, in the VBA code, we have to find the first derivative of the function in order to find the root. We already have the VBA code to find the first derivative and we're going to use it again in Newton-Raphson Method.

The Newton-Raphson Method uses 2 terms of taylor series to approximate delta x as shown below.

f(x) = f(x

_{0}) + (x

_{N}- x

_{0})f'(x

_{0}) = 0

(x

_{N}- x

_{0})f'(x

_{0}) = -f(x

_{0})

x

_{N}- x

_{0}= -f(x

_{0})/f'(x

_{0})

delta x = -f(x

_{0})/f'(x

_{0})

The followings are the procedure to find the root using Newton-Raphson Method.

- Guess the initial value of the root --> select x
_{0} - Calculate delta x using the formula as shown above
- Calculate x
_{N}using x_{N}= x_{0}+ delta x - Check whether the error of x
_{N}is within the allowable tolerance or not --> abs(x_{N}- x_{0}) < tolerance

' ================================================

' Created by Suparerg Suksai

' Mechanical Design Handbook

' http://mechanical-design-handbook.blogspot.com

'

' The Newton-Raphson Method - Numerical Methods

' ================================================

Function f(x As Double) As Double

f=Exp(-x)-x ' This is the function we want to find the root

End Function

Function fDeriv(x As Double) As Double

...

...

End Function

Function RootNewtonRaphson(x0 As Double)

...

...

...

End Function

To calculate the root of e

^{-x}- x = 0 we then type the following formula in the Microsoft Excel spreadsheet,

In any cell, type "=RootNewtonRaphson(1)", where 1 is the guessing value of the root.

The program will then show the result of 0.567143290409784.

We can recheck the calculation result by entering the following formula into excel,

=exp(-0.567143290409784)-0.567143290409784

Then the result is 0. That means one of the roots of of e

^{-x}- x = 0 is 0.567143290409784

FREE DOWNLOAD AN EXCEL FILE WITH VBA CODE OF NEWTON-RAPHSON ROOT FINDING METHOD

Extract the zip file with password: mechanical-design-handbook.blogspot.com

## No comments:

Post a Comment