Question: // in C++ : in the following code : #include #include using namespace std; const double eps = 1.0; double f(double x) { return 4

// in C++ : in the following code :

#include #include using namespace std; const double eps = 1.0; double f(double x) { return 4 * pow(x, 3) - 6 * pow(x, 2) + 7 * x - 2.3; } double bisect(double xl, double xu) { double iter = 0; double xr = 0; double xrold = 0; double error = 0; do { xrold = xr; xr = (xl + xu) / 2; error = abs((xr - xrold) / xr) * 100;

cout _getch();

if (f(xl) * f(xr) > 0) { xl = xr; } else { xu = xr;

} iter++;

} while (error > eps);

return xr; } int main() {

double xl, xu, root; cout cin >> xl; cout cin >> xu; if (f(xl) * f(xu) { root = bisect(xl, xu); cout }

else

{ cout

_getch();

return 0; } }

The Question is :

1 - Re Write this code in recursive way

2- Re write the code to make the output of the code in the first line don't contain Error ( first line only )

3- add line/s : if f(xl)*f(xr) = 0 get out from the function and say last xr you arrived to it is the ( answer )

Please put the 3 requirements in the same Code .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!