I need help with the body of this program. Can someone give me a reference or example to look on to give me an idea. This is what I have so far. Please help. I am very frusturated at this.
using namespace std;
bool isolate_zero( double left, double right, double &zero);
double cubic( double x );
int main( int argc, char* argv )
return ( 0 );
// Definition of isolate_zero
bool isolate_zero( double left, double right, double &zero)
// Definition of cubic
double cubic( double x )
double cubic( double c1 )
// cout << "cubic = " << c1 << "when x is 2" << endl;
This is assignment.
Write a program that uses two functions to find one real zero of a polynomial. The main program will send a left and right limit value to the first function.
The first function’s prototype should be something like:
bool isolate_zero(double left, double right, double &zero);
This function returns true if it discovered a zero and false otherwise. If the y value of the cubic is positive at both limits, or negative at both limits, then the function returns false. If the y value of the cubic is positive at one of the limits and negative at the other, then the function will find the real zero that must lie between those two limits. It should use a midpoint approach by repeatedly finding the y value at the midpoint, deciding which side of the midpoint contains the zero, and then replacing one of the limits with the midpoint. To decide whether it has found a zero or not, the function should use a tolerance of 1e-12. That value should be a global constant.
The second function has the prototype:
double cubic(double x);
It calculates a cubic similar to the function on page 288 of your book, but the four constants should be global variables rather than function arguments.
Test your program with the cubic x3-5x2+4x+3.