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

Bisection and Regula Falsi Methods

The document contains three programs that implement numerical methods for finding roots of equations. Program 1 uses the Bisection Method for a polynomial function, Program 2 applies the same method for a transcendental equation, and Program 3 utilizes the Regula Falsi Method for root finding through linear interpolation. Each program includes the necessary code and logic to compute the roots with specified precision.

Uploaded by

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

Bisection and Regula Falsi Methods

The document contains three programs that implement numerical methods for finding roots of equations. Program 1 uses the Bisection Method for a polynomial function, Program 2 applies the same method for a transcendental equation, and Program 3 utilizes the Regula Falsi Method for root finding through linear interpolation. Each program includes the necessary code and logic to compute the roots with specified precision.

Uploaded by

sainivinit7723
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program 1: Bisection Method (Algebraic Equation)

Finds the root of a polynomial function using the Bisection Method.


#include <iostream>
#include <cmath>
using namespace std;

double f(double x) { return x * x * x - x - 2; }

int main() {
double a = 1, b = 2, c;
while (fabs(a - b) >= 0.0001) {
c = (a + b) / 2;
if (f(a) * f(c) < 0) b = c;
else a = c;
}
cout << "Root = " << c << endl;
return 0;
}

Program 2: Bisection Method (Transcendental Equation)


Solves equations like 3x - cos(x) - 1 = 0 using the Bisection Method.
#include <iostream>
#include <cmath>
using namespace std;

double f(double x) { return 3*x - cos(x) - 1; }

int main() {
double a = 0, b = 1, c;
while (fabs(a - b) >= 0.0001) {
c = (a + b) / 2;
if (f(a) * f(c) < 0) b = c;
else a = c;
}
cout << "Root = " << c << endl;
return 0;
}

Program 3: Regula Falsi Method


Uses linear interpolation between two points to find a root.
#include <iostream>
#include <cmath>
using namespace std;

double f(double x) { return x * x * x - x - 1; }

int main() {
double a = 1, b = 2, c;
for (int i = 0; i < 20; i++) {
c = (a * f(b) - b * f(a)) / (f(b) - f(a));
if (f(a) * f(c) < 0) b = c;
else a = c;
}
cout << "Root = " << c << endl;
return 0;
}

You might also like