Im supposed to be finding the roots on a function using the secant method. Im pretty sure i have the equation right but it isnt giving me the right answer. The answer i am supposed to get is 0.0624 but im way off. I dont think its my actual equation im thinking something needs to be different in the loop but im not sure what. Any help would be appreciated.
the values im entering are
.02
.05
.000001
100
this is the Secant header file so i can easily test out different functions
#define FX0 pow(x0, 3) - 0.165*pow(x0, 2) + 3.993E-4
#define FX1 pow(x1, 3) - 0.165*pow(x1, 2) + 3.993E-4
and this is keyboard.h, just something he gave us to use instead of cout and cin
1 2 3 4 5 6 7 8 9 10 11 12
//pre: the string (character literal) that will prompt the user for input
//post: the input read from the keyboard interpreted as an int is returned
int readInt(constchar prompt[]);
//pre: the string that will prompt the user for input
//post: the input read from the keyboard interpreted as a double is returned
double readDouble(constchar prompt[]);
//pre: the string that will prompt the user for input
// the string to store the user input and the length of the input storage string
//post: the text read from the keyboard is copied into the storage string
void readString(constchar prompt[], char str[]);
Thanks for the help! Turns out I had the wrong variable with >= tolerance and I also needed parenthesis around the FX0 and FX1 in my equation which was why my answer was wrong.