Objective : - To find out the roots of an Algebraic & Transcendental Equations Using Newton-Raphson
Theory : -
Direct Methods or Closed Form formulas exist up to the polynomials of degree up to Four, For polynomials of degree more than four, no general formula exists for finding roots, Numerical methods are used to find out the roots. The numerical methods for the root finding problem are iterative in nature. The idea behind the iterative method is,
1. Start with an initial approximation (X0)
2. Construct a sequence of iterates using an iteration formula (Xk)
3. Until the sequence converges to a root of f(X) = 0
Two important aspects of the iterative methods are,
· Convergence Formulation
· Stopping Criteria
Newton-Raphson Method
In numerical analysis, Newton–Raphson method, named after Isaac Newton and Joseph Raphson, is a method for finding successively better approximations to the roots of a real-valued function. Newton Raphson method, is the fastest and simplest approach of all methods to find the real root of a nonlinear function. It is an open bracket approach, requiring only one initial guess. This method is quite often used to improve the results obtained from other iterative approaches.
Suppose we want to find an approximate solution to the equation
Suppose our first estimate is given by x0 = 2, We draw the tangent to the curve at x0. The point where the tangent meets the x-axis we call x1, Repeating the same steps each point x1, x2, x3 ... is closer to the root.
To carry out the iteration we need to find the points where the tangents meet the x-axis
Flow Chart:
Program:
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<math.h>
double f(double x);
double f(double x)
{
double a = pow(x,3)-x-11;
return a;
}
double df(double x);
double df(double x)
{
double b = 3*pow(x,2)-1;
return b;
}
void main()
{
clrscr();
double x=1,x1=1,e=1;
cout<<"\n Enter the Initial Guess :";
cin>>x1;
cout<<"\n Enter the desired accuracy limit :";
cin>>e;
cout<<"\n x(i) \t x(i+1) \t |x(i+1)-x(i)|"<<endl;
do
{
x=x1;
x1=x-(f(x)/df(x));
cout<<setprecision(5)<<x<<"\t"<<setprecision(5)<<x1<<"\t"<<abs(x1-x)<<endl;
}while(fabs(x1-x)>e);
cout<<"\n The Root of the Equation is:"<<x1<<endl;
getch( );
}
Output:
1. Find the Positive Root of f(X) = X4 – X- 10 = 0, to the correct of three decimal places
2. Find the real root of the equation f(X) = cos X + 1 = 0.
3. Using the Newton’s Iterative Method, Find the root of f(X) = Xlog10(X) = 1.2, to the correct of five decimal places