# Newton-Raphson Method – Examples with Answers

The Newton-Raphson method is an algorithm used to find the roots of a function. It is an iterative method that uses the derivative of the function to improve the accuracy of the root estimation at each iteration.

In this article, we will look at a brief introduction to the Newton-Raphson method, including its steps and advantages. We will also provide examples of using the method to find the root of a function.

##### CALCULUS

Relevant for

Learning about the Newton-Raphson method with examples.

See examples

##### CALCULUS

Relevant for

Learning about the Newton-Raphson method with examples.

See examples

## Steps to apply the Newton-Raphson method

The Newton-Raphson method is an iterative algorithm for finding the roots of a function. To use the method, follow these steps:

#### 1. Choose an initial value for x.

This value is an estimate where we expect there to be a root.

#### 4. Use the values found to update the root estimate using the following formula:

$$x_{r+1}=x_{r}-\frac{f(x_r)}{f^{\prime}(x_r)}$$

#### 5. Repeat steps 2-4 until the root estimate converges to an accurate value.

One of the main advantages of the Newton-Raphson method is that it can converge to the root of a function quickly, often in a few iterations.

In addition, the method can handle functions of any complexity, including nonlinear functions. This makes it an efficient algorithm for finding roots of complex functions.

Another advantage of the Newton-Raphson method is that it uses the derivative of the function to approximate the root, which can provide a more accurate estimate of the root compared to other methods that don’t use derivatives.

However, the Newton-Raphson method also has some drawbacks. One of the main drawbacks is that the method may not converge if the initial estimate is too far from the true root.

In addition, the method may converge to a local minimum or maximum rather than to the global minimum or maximum, which may lead to an incorrect estimate of the root.

Finally, the method requires the calculation of derivatives, which can be difficult for some functions.

## Newton-Raphson method – Examples with answers

### EXAMPLE 1

Use the Newton-Raphson method to find a negative root of the following cubic polynomial:

$$x^3-2x+1$$

Use as a starting point the value $latex x_0=-1.5$ to find by successive approximations the value of the root to three decimal places of precision.

We follow these steps to apply the Newton-Raphson method:

1) Define the function whose zeros or roots are to be found, in this example, it is: $latex f(x)=x^2-2x+1$

2) Find the derivative of this function: $latex f^{\prime}(x)= 3x^2-2$

3) Choose the starting point, in our example this value is given as follows: $latex x_{0}=-1.5$

4) Evaluate the function and its derivative at x₀: $latex f(x_{0})= 0.625$; $latex ~f^{\prime}(x_{0})= 4. 75$

5) Apply the Newton-Raphson iterative formula to find a first estimate:

$$x_{1}=x_{0}-\frac{f(x_{0})}{f^{\prime}(x_{0})}$$

$$x_{1}= -1. 6316$$

6) Repeat steps 4) and 5) until the estimate matches the desired number of decimal places.:

$latex f(x_{1})= -8. 0187×10^{-2}~~$ $latex ~~ f^{\prime}(x_{1})= 5. 9861$

$$x_{2}=x_{1}-\frac{f(x_{1})}{f^{\prime}(x_{1})}~~~~ x_{2}= -1. 6182$$

$latex f(x_{2})= -8. 7589×10^{-4} ~~$ $latex ~~ f^{\prime}(x_{2})= 5. 8556$

$$x_{3}=x_{2}-\frac{f(x_{2})}{f^{\prime}(x_{2})}~~~~ x_{3}= -1. 618$$

7) In this example, it was only necessary to take 3 iterations since the three decimal places have been repeated between the second and third iteration.

The value for the root is taken as the value of the last iteration: Solution: $latex x=-1.618$.

### EXAMPLE 2

Find to the nearest three decimal places the value of x that satisfies the following equation:

$$ln(x)=2$$

The function whose zeros (or roots) are to be found is defined. Its derivative is also calculated.

$$f(x)=ln(x)-2$$

$$f^{\prime}(x)= \frac{1}{x}$$

The function is analyzed to take an initial value. For example, notice that $latex f(7)=-0.054$ and $latex f(8)=+0.079$, which tells us that the root is between 7 and 8.

We will take as initial value 8, $latex x_{0}=8$:

$latex f(x_{0})= 7. 9442×10^{-2}~~$ $latex ~~ f^{\prime}(x_{0})= 0.125$

$$x_{1}=x_{0}-\frac{f(x_{0}}{f^{\prime}(x_{0})} ~~~~ x_{1}= 7. 3645$$

$latex f(x_{1})= -3. 3332×10^{-3}~~$ $latex ~~ f^{\prime}(x_{1})= 0.13579$

$$x_{2}=x_{1}-\frac{f(x_{1}}{f^{\prime}(x_{1})} ~~~~ x_{2}= 7. 389$$

$latex f(x_{2})= -5. 5429×10^{-6}~~$ $latex ~~ f^{\prime}(x_{2})= 0.13534$

$$x_{3}=x_{2}-\frac{f(x_{2}}{f^{\prime}(x_{2})} ~~~~ x_{3}= 7. 3891$$

We conclude that the solution of the equation ln(x)=2 is x=7.389 to the nearest three decimal places.

### EXAMPLE 3

Find the value of x that satisfies the following equation:

$$x^x = 5$$

The given equation is equivalent to:

$$x^x – 5 = 0$$

We define the function f: $latex f(x)= x^x – 5$

If the value that cancels the function is found, then the original equation has been solved.

Since this is a non-linear equation, it is necessary to find the solution by means of a numerical method, such as the Newton-Raphson method.

To apply this method it is necessary to calculate the derivative of the function f(x), which we will call f‘(x):

$$f'(x) = x^x (ln(x) +1)$$

If $latex x_i$ is a value close to the root, an even closer value is: $latex x_{i+1} = x_i – \frac{f(x_i)}{f'(x_i)}$.

If we repeat the process with the new value obtained, we will have a value even closer to the root. Repeating successively, we can have an accurate solution.

In this example, we will take as a starting point the value $latex x_0 = 2$ and as the following table shows, with only four iterations the value of x is found, with an accuracy of 6 decimal places:

$latex |x_{4}-x_{3}|=0.0000001131$

### EXAMPLE 4

Interpret geometrically the meaning of the formula for the Newton-Raphson method:

$$x_{i+1} = x_i – \frac{f(x_i)}{f'(x_i)}$$

The geometric interpretation is as follows:

In the graph of the function $latex y=f(x)$, the value $latex x=x_i$ is taken, and its corresponding value $latex y_i = f(x_i)$ is obtained. This represents a point P of coordinates $latex (x_i, f(x_i))$ on the curve of the function $latex f(x)$.

If the line tangent to the curve is drawn through that point, then that line intersects the x-axis at the point $latex x_{i+1}$.

Recalling that the slope of the tangent line to the curve of the function $latex f(x)$ is its derivative $latex f'(x)$, then the slope of the tangent line at the point P is $latex f'( x_i)$.

But the slope is also the tangent of the angle of inclination of the line at the point of intersection with the x-axis, which is calculated as follows:

$$f'(x_i) = \frac{f(x_i)-0}{x_i – x_{i+1}}$$

If we isolate $latex x_{i+1}$ from the above equation, then we obtain the formula for the Newton-Raphson method:

$$x_{i+1} = x_i – \frac{f(x_i)}{f'(x_i)}$$

### EXAMPLE 5

Find the solutions to the following equation:

$$cos(x) = x^2$$

1.- This is a nonlinear equation that doesn’t have an exact analytical solution.

2.- We define the function $latex f(x) = cos(x) – x^2$. The zeros of this function, that is the values of x that satisfy $latex f(x)=0$ are the solutions to the original equation.

3.- Sketching a graph of the function $latex f(x)$, we have:

4.- From the graph, we see that the function has two roots, one close to the value x=-1 and the other to the value x=+1.

5.- To more precisely determine the value of the roots of the function f(x), the Newton-Raphson method is used. This method requires the derivative of $latex f^{\prime}(x)$, which is $latex f^{\prime}(x) = -\sin(x)-2x$.

6.- The method also requires an initial value x0 to be provided, such that $latex f'(x_0) \neq 0$ and that it is as close as possible to the true value of the root.

7.- To find the first root, we take as starting point x0 = -1. We apply recursively the formula of the method, starting from i=0 to i=4. The results are shown below:

The value of the first root is: $latex x_{r1} = -0.824132312$ where the first eight decimal places are exact, and the ninth is estimated.

8.- If $latex x_{0} = +1$ is taken as the starting point, the Newton-Raphson method, after four iterations, gives the second root: $latex x_{r2} = +0.824132312$, a result that could have been expected due to the symmetry of the function f(x).

### EXAMPLE 6

Find the roots of the function:

$$tgh(x) + x^2 -1$$

It is convenient to sketch the graph of the function to get an idea of the location of the roots. One of the roots is positive (close to +0.5) and the other is negative (close to -1.5).

The Newton – Raphson method requires calculating the derivative of f(x):

$$f'(x) = 1 – tgh^2(x) +2x$$

Starting with the initial value $latex x_{0} = 0$, in five iterations of the formula $latex x_{i+1} = x_i – \frac{f(x_i)}{f'(x_i)}$, the value of the positive root is obtained with eight decimal places of precision:

The positive root of the given function is: 0.65295190.

To obtain the negative root, we start from a value close to the same, $latex x_{0}=-1.5$.

The negative root of the given function is: -1.3707713181, with a precision of ten decimal places.

### EXAMPLE 7

Solve the following equation using the Newton-Raphson method:

$$e^x = 2 – x^2$$

with a minimum of four decimal places.

1.- We start by sketching the graph of $latex e^x$ and $latex 2-x^2$. The intercept points are the graphical solutions to the problem.

There are two x-intercepts, which correspond to the solutions of the given equation. One of them has an x-coordinate value close to -1.5 and the other, an x-coordinate close to +0.5.

3.- To apply the Newton-Rapson method, we define the function:

$$f(x) = e^{x} -2 + x^2$$

the values where $latex f(x)=0$ will be the solutions to the given equation.

4.- Finding the derivative of f(x):

$$f'(x) = e^{x} + 2x$$

5.- To find the first root of f(x), we take as starting point of the method the value $latex x_{0}=-1.5$.

6.- We apply Newton Raphson’s formula successively until the desired accuracy is reached:

$latex x_{i+1} = x_i – \frac{f(x_i)}{f'(x_i)}$, starting with the initial value, $latex x_{0}$ to get $latex x_{1}$. Then with $latex x_{1}$ to get $latex x_{2}$. It is repeated until the difference between the last value minus the previous one has an absolute value less than or equal to 0.00001

The numerical results are shown below:

obtaining the value of the first solution: x=-1.31597

8.- The second solution to the equation is close to +0.5, so this will be used as a starting value to obtain the solution with the requested precision of at least four decimal places.

9.- Since we started with a value quite close to the exact root, we obtained a result with a precision of three decimal places in only two iterations:

The second solution to the given equation is: x=+0.53727

### EXAMPLE 8

Use Newton-Raphson method to obtain an approximation of at least three exact decimal places of:

$$\sqrt[6]2$$

The equation to solve is $latex \sqrt[6]2 =x$ which is equivalent to:

$latex x^6 -2 =0$ con x>0.

Then, we define $latex f(x) = x^6-2$ whose derivative is $latex f^{\prime}(x)=6x^5$.

Iteratively applying the formula for the Newton-Raphson method $latex x_{i+1} = x_i – \frac{f(x_i)}{f'(x_i)}$ and starting from $latex x_{0}=1$, we obtain:

Therefore:

$$\sqrt[6]2=1.12246$$

### EXAMPLE 9

Find an approximate value with at least three decimal places for:

$$\sqrt {\sqrt 2}$$

The equation to solve is $latex \sqrt[4]2 =x$ which is equivalent to:

$latex x^4 -2 =0$ con x>0.

Then, we define $latex f(x) = x^4-2$ whose derivative is $latex f'(x)=4x^3$.

Iteratively applying the formula for the Newton-Raphson method $latex x_{i+1} = x_i – \frac{f(x_i)}{f'(x_i)}$ and starting from $latex x_{0}=1$, we obtain:

Therefore:

$$\sqrt {\sqrt 2}= 1.18920$$

### EXAMPLE 10

Use the Newton-Raphson method to find a decimal approximation for:

$$ln(13)$$

The equation to be solved is: $latex ln(13)=x$

Taking the exponential function with base e in both sides, we have $latex e^x=13$.

Now, we define the function $latex f(x)= e^x – 13$.

The derivative of f is: $latex f'(x)=e^x$.

We begin the iterative process with the formula $latex x_{i+1} = x_i – \frac{f(x_i)}{f'(x_i)}$, with the initial value $latex x_{0} = 2$, obtaining the following values:

As a final result, we have:

$$ln(13) = 2.5649$$

## Newton-Raphson method – Practice problems

Newton-Raphson method quiz
You have completed the quiz!

#### Use the Newton Raphson method to find the root of $latex x\ln (x)=2$ that lies between $latex x=2$ and $latex x=3$.

Write the answer to three decimal places.

$latex x=$