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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
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!!