Professional Documents
Culture Documents
Submitted By:
Ayush Timalsina
Jaya Multiple Campus
BCA , 4th Semester
Contents:
1. Introduction
2. Advantages And Disadvantages
3. Algorithm
4. Program
5. Conclusion
6. Reference
Introduction:
Graphically,
Xn = Xn -1 – F(Xn-1)
F^-1 (Xn-1)
Advantages:
1. One of the fastest convergences to the root.
2. Converges on the root quadratic.
3. Near a root, the number of significant digits approximately
doubles with each step.
Disadvantages:
1. May be too far from local root
2. Must find the derivative
3. Poor global convergence properties
4. Dependent on initial guess
Algorithm:
1. Start
2. Input initial guess x0 and error e.
3. Evaluate f ^-1 (x)
4. Using x0 as initial guess, find new value
x1=x0- f(x0)
f^-1(x0)
5. If |x1 - x0| <e, root = x1, go to 6
Else,
x0= x1
go to step 4
6. Stop
Program:
#include<stdio.h>
#include<math.h>
float f(float x)
{
return x*x - 3*x + 2;
}
float df (float x)
{
return 2*x - 3 ;
}
int main()
{
int itr, maxmitr;
float h, x0, x1, allerr;
printf("\nEnter x0, allowed error and maximum iterations\n");
scanf("%f %f %d", &x0, &allerr, &maxmitr);
for (itr=1; itr<=maxmitr; itr++)
{
h=f(x0)/df(x0);
x1=x0-h;
printf(" At Iteration no. %3d, x = %9.6f\n", itr, x1);
if (fabs(h) < allerr)
{
printf("After %3d iterations, root = %8.6f\n", itr, x1);
return 0;
}
x0=x1;
}
printf(" The required solution does not converge or iterations are
insufficient\n");
return 1;
}
Output:
Conclusion: