# Matlab Tutorials | Examples

## Practice 3:

### Finding Root of a Number by Newton-Raphson Method

In numerical analysis, Newton’s method (also known as the Newton– Raphson method), named after Isaac Newton and Joseph Raphson, is perhaps the best known method for finding successively better approximations to the zeroes (or roots) of a real-valued function. Newton’s method can often converge remarkably quickly; especially if the iteration begins “sufficiently near” the desired root.

Given a function ƒ(x) and its derivative ƒ ‘(x), we begin with a first guess x0. A better approximation x1 is: This iterative solution can be used in finding the root of a number. Take f(x) and f ′(x)

as: For example, if a=400, this iteration should give x approximately as 20.

Write a MatLab code that will do the following:

1. Get a number of iterations, the initial guess, and ε from the user.
2. Find the root by using the Newton-Raphson method.
3. Find the exact root using the sqrt() function.
4. If the difference between the real root (found in step 3) and the root found by

Newton-Raphson method is smaller than ε, display the root; otherwise, display “the root could not be found”.

Use only scalar variables; no vectors or matrices. ε (epsilon) is the sensitivity, which is used to test the accuracy of the solution.

Solution: