FINAL1
FINAL1
THEORY : Bisection Method is one of the simplest, reliable, easy to implement and
convergence guaranteed method for finding real root of non-linear equations. It is also known as
Binary Search or Half Interval or Bolzano Method.
Bisection method is bracketing method and starts with two initial guesses say x0 and x1
Bisection method is based on the fact that if f(x) is real and continuous function, and for two
initial guesses x0 and x1 brackets the root such that: f(x0)f(x1) <0 then there exists atleast
Root is obtained in Bisection method by successive halving the interval i.e. If x0 and x1 are
x2 = (x0 + x1)/2
If f(x0)f(x2)<0 then root lies between x0 and x2. If f(x0)f(x2)> 0 then root lies between x1
and x2.
And then process is repeated until we find the root within desired accuracy.
ALGORITHM:
1. Start
8. Display x2 as root.
9. Stop
CODE
#include <stdio.h>
#include <math.h>
#define e 0.001
float func(float x) {
return y;
int main() {
int i;
up:
scanf("%f", &x0);
scanf("%f", &x1);
} else {
goto up;
do {
x2 = (x0 + x1) / 2;
if (func(x0) * func(x2) < 0) {
x1 = x2;
} else {
x0 = x2;
i++;
return 0;
}
GRAPH:
VIVA QUESTIONS:
Newton Raphson Method is an open method and starts with one initial guess
for finding real root of non-linear equations.
ALGORITHM:
1. Start
4. Input initial guess (x0), tolerable error (e) and maximum iteration (N)
12. Stop
CODE
#include <stdio.h>
#include <math.h>
#define e 0.0001
double func(double x) {
}
double dfunc(double x) {
int main() {
scanf("%f", &x0);
int i = 1, maxitr;
scanf("%d", &maxitr);
x1 = x0 - (func(x0) / dfunc(x0));
break;
x0 = x1;
i++;
if (i > maxitr) {
return 0;
}
OUTPUT:
GRAPH:
VIVA QUESTIONS:
THEORY: SecantMethod is open method and starts with two initial guesses for finding real
root of non-
linear equations.
x2 =x1 -(x1-x0)*f(x1)/(f(x1)-f(x0) )
And an algorithm for the Secant method involves repetition of the above process i.e. we use
to find x3 and so on until we find the root within the desired accuracy.
x1 and x2
ALGORITHM:
1. Start
3. Input initial guesses (x0 and x1), tolerable error (e) and maximum iteration (N)
5. If f(x0) = f(x1) then print "Mathematical Error" and goto (11) otherwise goto (6)
8. If i>= N then print "Not Convergent" and goto (11) otherwise goto (9)
9. If |f(x2)| > e then set x0 = x1, x1 = x2 and goto (5) otherwise goto (10)
#include <math.h>
double func(double x) {
return a / b;
int main() {
printf("Secant Method\n");
scanf("%lf", &x0);
scanf("%lf", &x1);
x2 = secant(x0, x1);
break;
}
x0 = x1;
x1 = x2;
return 0;
OUTPUT:
GRAPH :
VIVA QUESTIONS:
c. What is the formula for finding the root by using the secant method?