Here myFunction evaluates the value based on x
Say
myFunction(2), here x=2 passes to function arguments, so the result will
Then
Assigned
x_lower=0;
x_upper=5;
x_mid=(x_lower+x_upper)/2;
While loop continue till Absolute(myFunction(x_mid)) is greater than 0.01
{
Then replace the value of x_mid, x_lower, x_upper based on if condition
If true
x_lower change to x_mid
otherwise
x_upper=x_mid;
x_mid=(x_lower+x_upper)/2;
end if
Re-evaluate x_mid again based on present x_lower and x_upper value
Then print the x_mid value
Note: Text the code with some example, change the my function expression and see the results
Hope it helps!
Best Answer