Numerical Computing with MATLAB

This chapter describes several basic methods for computing zeros of functions and then combines three of the basic methods into a fast, reliable algorithm known as zeroin .
Let's compute ?2. We will use interval bisection, which is a kind of systematic trial and error. We know that ?2 is between 1 and 2. Try
. Because x 2 is greater than 2, this x is too big. Try
. Because x 2 is less than 2, this x is too small. Continuing in this way, our approximations to ?2 are
Here is a MATLAB program, including a step counter.
M = 2 a = 1 b = 2 k = 0; while b-a > eps x = (a + b)/2; if x^2 > M b = x else a = x end k = k + 1; end
We are sure that ?2 is in the initial interval [ a,b]. This interval is repeatedly cut in half...