C code to implement Bisection method . Compiled in DEV C++
#include<stdio.h> #include<conio.h> #include<math.h> #include<stdlib.h> float f(float x) { float sum; sum=pow(x,3)+x+3; return sum; } main() { float a,b,c,y0,y1,m; step: printf("enter the value of a,b and c "); scanf("%f%f%f",&a,&b,&c); y1=f(a); y0=f(b); if(y0*y1>0) { goto step; } step1: m=(a+b)/2; if(f(m)==0) { printf("the root is : %f",m); exit(0); } else { if (y1*f(m)<0) b=m; else a=m; } if(a-b>c) { goto step1; } printf("the root is :%f",m); getch(); }
You might be also interested in :
- Gauss Elimination Method
- Lagrange interpolation
- Newton Divided Difference
- Runge Kutta method method
- Taylor series method
- Modified Euler’s method
- Euler’s method
- Waddle’s Rule method
- Bisection method
- Newton’s Backward interpolation
- Newton’s forward interpolation
- Newtons rapson method
- Regular Falsi method
- SIMPSON’S RULE
- TRAPEZOIDAL RULE