Write a program which uses the Bisection Algorithm to solve the equation x^3 + 5
ID: 3645112 • Letter: W
Question
Write a program which uses the Bisection Algorithm to solve the equationx^3 + 5 = e^x for x >= 0.
Your program should prompt the user to input values of x = a and x = b. If f (a) and
f (b) are not of opposite sign, the program should continue to prompt the user for values of
x = a and x = b until values of x = a and x = b are entered such that f (a) and f (b) are of
opposite sign.
Maximum allowable error should be 10^-5.
I have everything except I cant get it to show the answer to the equation.
Explanation / Answer
main() { float a,b,c,x1,x2,x,series; double d; printf("enter a,b,c and x1(pos) & x2(neg)"); scanf("%f%f%f%f%f", &a, &b, &c, &x1, &x2); read: x = (x1 + x2) / 2; series = a * x * x + b * x + c; d = fabs(series); if (d > 0.0001) { if (x * x1 < 0) x = x2; else x = x1; goto read; } else { printf("ans=%f", x); } return 0; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.