bisection method in c

bisection method :
Let,the function f(x) be continuous between a and b.for definiteness let f(a) be negative and f(b) be positive.then there is a root of f(x)=0,lying between a and b.
let,first approximate be,
x0 = 1/2(a+b)
Now if f(x0)=0 then, x0 is a root of f(x)=0,otherwise root lies between a or x1 & b according as f(x0) is positive or negative.
thus,as before we bisect the interval and continue the process until root is found to desired accuracy.
coding:
- we take equation is x-cosx.
- first create function name of bisection.
- calling this function and after put the condition is f(lying point)*f(second lying point)>0.
- after put the bisection equation:c=1/2(a+b).
output:
0 comments: