Programmer-Defined Functions- isolate_zero?

Choose one of the options listed below. Your program must contain at least one programmer-defined function.
Option (1) 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:

Hello All,

This is my assignment and I am confused about about how to put in the actual values for the problem statement.

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);

Here is what I have:

 ``123456789101112131415161718192021222324252627282930313233`` ``````#include #include #include #include using namespace std; bool isolate_zero( double left, double right, double &zero); double cubic( double x ); int main( int argc, char* argv[] ) { std::cin.get(); return ( 0 ); } // Definition of isolate_zero // I do not know the defintion of isolate_zero bool isolate_zero( double left, double right, double &zero) { // body- Can someone help or give me a reference? } cubic = x^3 - 5x^2 + 4x + 3 double cubic( double x ) { // body- Same }``````

I know it isn't much to go off of, but I am having trouble with any direction to go from this. I have looked in the book, but am really confused. Please Help!!
Last edited on
 ``12345678910111213141516171819202122232425262728`` ``````#include #include #include #include using namespace std; bool isolate_zero( double left, double right, double &zero); double cubic( double x ); int main( int argc, char* argv[] ) { std::cin.get(); return ( 0 ); } // Definition of isolate_zero bool isolate_zero( double left, double right, double &zero) { // body } // Definition of cubic double cubic( double x ) { // body }``````

You have to fill in the bodies of the functions.
Last edited on
Can You help me with the defintion of the isolate zero and the body/ For the body, can you give me a reference. In my example from class, there is a trapezoid problem, but with the isolate zero, it is very unclear to me at this point.
Last edited on
Topic archived. No new replies allowed.