0% found this document useful (0 votes)
46 views2 pages

Name-Akshay Bora ROLL NO. - 7682 Question - Find The Roots of The Equation Using Secant Method. Also Print The Table. Program

The document is a program that uses the secant method to find the roots of the equation f(x)=x^3-2x+3. The program takes initial guesses for the roots as input, calculates successive approximations of the roots, and prints the results to a table. It iterates until the difference between successive approximations is less than the desired accuracy of 0.0001. The output shows the table with 19 iterations converging to a root of -1.89338.

Uploaded by

Akshay Bora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views2 pages

Name-Akshay Bora ROLL NO. - 7682 Question - Find The Roots of The Equation Using Secant Method. Also Print The Table. Program

The document is a program that uses the secant method to find the roots of the equation f(x)=x^3-2x+3. The program takes initial guesses for the roots as input, calculates successive approximations of the roots, and prints the results to a table. It iterates until the difference between successive approximations is less than the desired accuracy of 0.0001. The output shows the table with 19 iterations converging to a root of -1.89338.

Uploaded by

Akshay Bora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

NAME- AKSHAY BORA

ROLL NO. -7682


Question - Find the roots of the equation using Secant
Method. Also Print the table.
PROGRAM:
#include <iostream>
#include<iomanip>
#include<math.h>
#define f(x)(x*x*x-2*x+3)
using namespace std;
int main()
{
float a,b,x,tol;
int n=1;
cout<<"The method prints the roots uding SECANT METHOD "<<endl;
cout<<"Give your initial Guesses for the roots :"<<endl;
cout<<"\ta = ";cin>>a;cout<<"\n\tb = ";cin>>b;
cout<<"Give the Desired accuracy : ";cin>>tol;
cout<<"Sl.No"<<setw(11)<<"x_0"<<setw(15)<<"f(x_0)"<<setw(15)<<"x_1"<<setw(
15)<<"f(x_1)"<<setw(15)<<"Root"<<endl;
do
{ x=a;

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 . . .

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy