# The Newton-Raphson Method | Numerical Methods Lesson 5

The Newton-Raphson method is an iterative numerical method used to find the roots of a function. The method starts with an initial guess for the root and then iteratively refines this guess until the desired level of accuracy is achieved.

The general procedure for the Newton-Raphson method is as follows:

1. Start with an initial guess for the root, denoted by x0.
2. Compute the value of the function at x0, denoted by f(x0).
3. Compute the derivative of the function at x0, denoted by f'(x0).
4. Calculate the next approximation of the root using the formula:

x1 = x0 – f(x0) / f'(x0)

1. Check if the difference between x1 and x0 is within the desired level of accuracy. If not, repeat steps 2-4 with x1 as the new guess for the root.
2. Continue iterating until the desired level of accuracy is achieved.

The formula in step 4 is based on the idea of using the tangent line at x0 as an approximation of the curve. The intersection of the tangent line and the x-axis is then taken as the next guess for the root.

Note that the Newton-Raphson method may not always converge to a root or may converge to a wrong root if the initial guess is not close enough to the actual root or if the function has a singularity or a multiple root. Therefore, it is important to carefully choose the initial guess and check the convergence of the method.

## Example.

Example 1:

Let’s take the function f(x) = x^3 – 2x – 5 and find one of its roots using the Newton-Raphson method.

1. Choose an initial guess for the root, let’s say x0 = 2.
2. Compute the value of the function at x0: f(x0) = 2^3 – 2(2) – 5 = 1.
3. Compute the derivative of the function at x0: f'(x0) = 3x^2 – 2 = 10.
4. Calculate the next approximation of the root using the formula:

x1 = x0 – f(x0) / f'(x0) = 2 – 1 / 10 = 1.9

1. Check the difference between x1 and x0: |x1 – x0| = |1.9 – 2| = 0.125. Since this is larger than our desired level of accuracy, we need to continue with the next iteration.
2. Set x0 = x1 and repeat steps 2-4 until the desired level of accuracy is achieved.

Let’s do another iteration:

1. Compute the value of the function at x1: f(x1) = (1.875)^3 – 2(1.875) – 5 = -0.327
2. Compute the derivative of the function at x1: f'(x1) = 3(1.875)^2 – 2 = 8.953
3. Calculate the next approximation of the root using the formula:

x2 = x1 – f(x1) / f'(x1) = 1.875 – (-0.327) / 8.953 = 2.095

1. Check the difference between x2 and x1: |x2 – x1| = |2.095 – 1.875| = 0.22. Since this is larger than our desired level of accuracy, we need to continue with the next iteration.
2. Set x1 = x2 and repeat steps 2-4 until the desired level of accuracy is achieved.

After repeating steps 2-4 a few more times, we eventually get an approximation of the root to be x = 2.0945514815.

Example 2:

Use the Newton-Raphson method to find a root of the function f(x) = x^3 – 2x^2 + 2.

Solution:

1. Choose an initial guess for the root, let’s say x0 = 1.
2. Compute the value of the function at x0: f(x0) = (1)^3 – 2(1)^2 + 2 = 1.
3. Compute the derivative of the function at x0: f'(x0) = 3(1)^2 – 4(1) = -1.
4. Calculate the next approximation of the root using the formula:

x1 = x0 – f(x0) / f'(x0) = 1 – 1 / (-1) = 2.

1. Check the difference between x1 and x0: |x1 – x0| = |2 – 1| = 1. Since this is larger than our desired level of accuracy, we need to continue with the next iteration.
2. Set x0 = x1 and repeat steps 2-4 until the desired level of accuracy is achieved.

Let’s do another iteration:

1. Compute the value of the function at x1: f(x1) = (2)^3 – 2(2)^2 + 2 = -2.
2. Compute the derivative of the function at x1: f'(x1) = 3(2)^2 – 4(2) = 4.
3. Calculate the next approximation of the root using the formula:

x2 = x1 – f(x1) / f'(x1) = 2 – (-2) / 4 = 2.5.

1. Check the difference between x2 and x1: |x2 – x1| = |2.5 – 2| = 0.5. Since this is larger than our desired level of accuracy, we need to continue with the next iteration.
2. Set x1 = x2 and repeat steps 2-4 until the desired level of accuracy is achieved.

After a few more iterations, we get an approximation of the root to be x = 1.5321 (rounded to 4 decimal places).