Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

Show that 15 is an inverse of 7 modulo 26.

Answered: 1 week ago