The bisection method is another way to find a real root of an equation f(x) = 0. We begin by finding two values, a and b, such that f(a) and f(b) have opposite signs; that is f(a) f(b) An...


The bisection method is another way to find a real root of an equation f(x) = 0. We begin by finding two values, a and b, such that f(a) and f(b) have opposite signs; that is f(a) f(b) <><><>


An approximation to the root r is the point m, midway between a and b. Thus,


m = (a + b) / 2






If f(a) x f(m) <><>



In practice, two issues must be considered. Because both f(a) and f(b) are approaching zero, their product can be too small to represent in floating-point notation. To avoid an error, you should test the signs of f(a) and f(b) separately instead of testing the sign of their product. Second, because a and b are real numbers, not integers, the computation of their midpoint (a + b) / 2 can lead to an error. Instead use the algebraically equivalent expression a + (b - a) / 2.


Define a class that implements the bisection method to find the root of the equation.


Use a private method to evaluate f(x).



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here