
ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff
Edition 2ISBN: 978-0131409095
ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff
Edition 2ISBN: 978-0131409095 Exercise 8
A root of a polynomial P ( x ) is a number c for which P ( c ) = 0. The bisection method is one scheme that can be used to find an approximate root of P ( x ) in some given interval [ a , b ], where P ( a ) and P ( b ) have opposite signs (thus guaranteeing that P ( x ) has a root in [ a , b ]). In this method, we begin by bisecting the interval [ a , b ] and determining in which half P ( x ) changes sign, because P must have a root in that half of the interval. Now bisect this subinterval and determine in which half of this subinterval P ( x ) changes sign. Repeating this process gives a sequence of smaller and smaller subintervals, each of which contains a root of P ( x ), as pictured in the following diagram. The process can be terminated when a small subinterval-say, of length less than 0.0001-is obtained or when P ( x ) has the value 0 at one of the endpoints:
Add and test a member function root() to the Polynomial class template so that, for a Polynomial object p,p.root (a,b) returns an approximate root of the polynomial in the interval [a, b] (if there is one), using the bisection method.
![A root of a polynomial P ( x ) is a number c for which P ( c ) = 0. The bisection method is one scheme that can be used to find an approximate root of P ( x ) in some given interval [ a , b ], where P ( a ) and P ( b ) have opposite signs (thus guaranteeing that P ( x ) has a root in [ a , b ]). In this method, we begin by bisecting the interval [ a , b ] and determining in which half P ( x ) changes sign, because P must have a root in that half of the interval. Now bisect this subinterval and determine in which half of this subinterval P ( x ) changes sign. Repeating this process gives a sequence of smaller and smaller subintervals, each of which contains a root of P ( x ), as pictured in the following diagram. The process can be terminated when a small subinterval-say, of length less than 0.0001-is obtained or when P ( x ) has the value 0 at one of the endpoints: Add and test a member function root() to the Polynomial class template so that, for a Polynomial object p,p.root (a,b) returns an approximate root of the polynomial in the interval [a, b] (if there is one), using the bisection method.](https://storage.examlex.com/SM6508/11eb7771_af9c_a3d8_894f_69e4686b4dca_SM6508_00.jpg)
Add and test a member function root() to the Polynomial class template so that, for a Polynomial object p,p.root (a,b) returns an approximate root of the polynomial in the interval [a, b] (if there is one), using the bisection method.
Explanation
Program Plan:
Polynomial.h:
• Include ...
ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff
Why don’t you like this exercise?
Other Minimum 8 character and maximum 255 character
Character 255