Name-Akshay Bora ROLL NO. - 7682 Question - Find The Roots of The Equation Using Secant Method. Also Print The Table. Program
Name-Akshay Bora ROLL NO. - 7682 Question - Find The Roots of The Equation Using Secant Method. Also Print The Table. Program
cout<<n<<"."<<setw(14)<<b<<setw(15)<<f(b)<<setw(15)<<a<<setw(15)<<f(a)<<se
tw(15)<<x<<endl;
x=a-(f(a)*(a-b))/(f(a)-f(b));
if(f(a)-f(b)==0) break;
b=a;
a=x;
n++;
}while(fabs(a-b)>tol);
cout<<"Thus the root of the Given equation is : "<<a;
return 0;
}
RESULT:
The method prints the roots uding SECANT METHOD
Give your initial Guesses for the roots :
a = -5
b=5
Give the Desired accuracy : 0.0001
Sl.No x_0 f(x_0) x_1 f(x_1) Root
1. 5 118 -5 -112 -5
2. -5 -112 -0.130435 3.25865 -0.130435
3. -0.130435 3.25865 -0.26811 3.51695 -0.26811
4. -0.26811 3.51695 1.60646 3.93291 1.60646
5. 1.60646 3.93291 -16.1176 -4151.74 -16.1176
6. -16.1176 -4151.74 1.58969 3.83793 1.58969
7. 1.58969 3.83793 1.57333 3.74793 1.57333
8. 1.57333 3.74793 0.892336 1.92586 0.892336
9. 0.892336 1.92586 0.172545 2.66005 0.172545
10. 0.172545 2.66005 2.78045 18.9344 2.78045
11. 2.78045 18.9344 -0.253716 3.4911 -0.253716
12. -0.253716 3.4911 -0.939616 4.04967 -0.939616
13. -0.939616 4.04967 4.03324 60.5422 4.03324
14. 4.03324 60.5422 -1.29609 3.41493 -1.29609
15. -1.29609 3.41493 -1.61467 2.01964 -1.61467
16. -1.61467 2.01964 -2.0758 -1.79289 -2.0758
17. -2.0758 -1.79289 -1.85895 0.293963 -1.85895
18. -1.85895 0.293963 -1.88949 0.0331457 -1.88949
19. -1.88949 0.0331457 -1.89338 -0.000753641 -1.89338
Thus the root of the Given equation is : -1.89329
--------------------------------
Process exited after 8.2 seconds with return value 0
Press any key to continue . . .