# 4. Newton Raphson Method

The Newton-Raphson method, also known as Newton’s method, is a technique for finding the roots of a real-valued function. The method starts with an initial guess for the root and then uses an iterative approach to improve the guess until the root is found with a desired level of accuracy.

The method is based on the idea that a root of a function can be approximated by a tangent line to the function at a nearby point. The x-intercept of the tangent line is a better approximation to the root than the original guess. This process is repeated, using the new approximation as the starting point, until the desired level of accuracy is achieved.

Here is an example of using the Newton-Raphson method to find the root of the function f(x) = x^3 – x – 2

Start with an initial guess for the root, say x0 = 1

Compute the function value, f(x0) = 1^3 – 1 – 2 = -2

Compute the derivative of the function, f'(x0) = 3*1^2 – 1 = 2

Compute the next approximation of the root, x1 = x0 – f(x0)/f'(x0) = 1 – (-2)/2 = 3/2

Compute the function value at x1, f(x1) = (3/2)^3 – (3/2) – 2 = -1/8

Repeat steps 3-5 until the desired level of accuracy is achieved.

In this example, the root of the function is found to be approximately 1.618 after a few iterations.

It’s important to note that the Newton-Raphson method requires the first derivative of the function to be calculated, and it is also only guaranteed to converge if the initial guess is sufficiently close to the root.