The Newton-Raphson method, also called Newton’s method is used to find an approximate root of a real-valued polynomial, f(x) = 0. It works on the idea that a straight-line tangent can be drawn to a continuous and differentiable function which can be used to approximate the root of the function. Newton-Raphson works in several steps in which it successively finds better approximations of the root of the function. An initial guess value of the root has to be provided and then using this method, that value can be used to better approximate the root. This initial guess is a value which is close to the exact root value. The formula for approximation of root is:

, where x0 is the initial guess of the root and x1 is the new approximated value of the root.

## Newton Raphson Method Program in C

## Newton Raphson Method Program in C ++

## Output of Newton Raphson Method Program in C and C++

In the above program, the newtonRaphson () is responsible for taking the coefficients of the polynomials from the user. These coefficients are then fed to the inputPolynomial () and the getDerivative () functions to get the values of the function and its derivative respectively. These values are then put in the above formula to obtain a new approximation of the root. This new value then becomes the initial value for the next iteration and then an even better approximation is calculated. The more this process is repeated, the more accurate the approximation is. Here the approximation calculated is accurate up to 5 decimal places.

Aayush Kumar Gupta is the founder and creator of ExploringBits, a website dedicated to providing useful content for people passionate about Engineering and Technology. Aayush has completed his Bachelor of Technology (Computer Science & Engineering) from 2018-2022. From July 2022, Aayush has been working as a full-time Devops Engineer.