In: Computer Science
Using the bisection method, find the root of the following function:
f(x)=cos(2x) - x
Use the following initial values: xl=0 and xu=2
NOTE: Perform only 3 iterations.
Find a root of an equation f(x)=cos(2x)-x between 0 and
2, using Bisection method
Solution:
Here cos(2x)-x=0
Let f(x)=cos(2x)-x
Here
x | 0 | 1 | 2 |
---|---|---|---|
f(x) | 1 | -1.4161 | -2.6536 |
Here f(0)=1>0 and f(1)=-1.4161<0
∴ Root lies between 0 and 1
1st iteration
:
Here f(0)=1>0 and f(1)=-1.4161<0
∴ Now, Root lies between 0 and 1
x0=0+12=0.5
f(x0)=f(0.5)=cos(1)-0.5=0.0403>0
2nd iteration
:
Here f(0.5)=0.0403>0 and f(1)=-1.4161<0
∴ Now, Root lies between 0.5 and 1
x1=0.5+12=0.75
f(x1)=f(0.75)=cos(1.5)-0.75=-0.6793<0
3rd iteration
:
Here f(0.5)=0.0403>0 and f(0.75)=-0.6793<0
∴ Now, Root lies between 0.5 and 0.75
x2=0.5+0.752=0.625
f(x2)=f(0.625)=cos(1.25)-0.625=-0.3097<0