Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The function where the bisection method is implemented shouldhave the following

ID: 3614672 • Letter: T

Question

The function where the bisection method is implemented shouldhave the following parameters and should return the followingvalue. The input parameters are:    -a function f whose root we want tocompute    -a and b are the left and right endpoint ofthe interval where a root of f we want to compute. This      interval should contain only one sucha root. If there are no roots in this interval, the programshould      stop and print the error message: "Noroots found."    -epsilon (=acceptable error) which should beset by the user (should be less then 1.0 but larger       than 0.0) The function should implement the following algorithm. Letf_a=f(a) and f_b=f(b) 1. Compute the funtion value at the midpoint of the interval(a and b are the endpoints of the interval). The midpoint iscomputed as (a+b)/2. 2.If f_mid is zero, the midpoint is the root. REturn theroot. 3.If f_mid is not zero and    a.) if f_mid*f_a<0.0, replace b with themidpoint    b.) if f_mid*f_b<0.0, replace a with themidpoint. 4. Repeat steps 1-3 in a while loop until the distance betweena and b is less then epsilon by using the function fabs (a-b) tofind the distance between a and b. Return midpoint of final interval as the root. Use this runction whose roots we are to compute: 3x^3-3x^2+0.2 (Although is has three roots, we are interested in roots inthese two intervals: [-1, 0] and [0, 0.5] The function where the bisection method is implemented shouldhave the following parameters and should return the followingvalue. The input parameters are:    -a function f whose root we want tocompute    -a and b are the left and right endpoint ofthe interval where a root of f we want to compute. This      interval should contain only one sucha root. If there are no roots in this interval, the programshould      stop and print the error message: "Noroots found."    -epsilon (=acceptable error) which should beset by the user (should be less then 1.0 but larger       than 0.0) The function should implement the following algorithm. Letf_a=f(a) and f_b=f(b) 1. Compute the funtion value at the midpoint of the interval(a and b are the endpoints of the interval). The midpoint iscomputed as (a+b)/2. 2.If f_mid is zero, the midpoint is the root. REturn theroot. 3.If f_mid is not zero and    a.) if f_mid*f_a<0.0, replace b with themidpoint    b.) if f_mid*f_b<0.0, replace a with themidpoint. 4. Repeat steps 1-3 in a while loop until the distance betweena and b is less then epsilon by using the function fabs (a-b) tofind the distance between a and b. Return midpoint of final interval as the root. Use this runction whose roots we are to compute: 3x^3-3x^2+0.2 (Although is has three roots, we are interested in roots inthese two intervals: [-1, 0] and [0, 0.5]

Explanation / Answer

Please rate! #include #include using namespace std; double equation(double x) {     return (3.0*pow(x,3) - 3.0*pow(x,2) +0.2);    } double bisection(double a, double b, double epsilon) {     double f_a, f_b, f_mid, mid;         while (fabs(a - b) > epsilon) {         mid = (a + b) / 2;         f_mid =equation(mid);         if (f_mid == 0.0) {            returnmid;         }         else {            f_a =equation(a);            f_b =equation(b);           if(f_mid*f_a < 0.0)              b = mid;           if(f_mid*f_b < 0.0)              a = mid;         }      }      return mid; } int main() {      double epsilon = 0.0001;                           cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote