Question: In this task, a simple implementation of the bisection method for finding roots of continuous functions is to be developed. Let f: [ a ,
In this task, a simple implementation of the bisection method for finding roots of continuous functions is to be developed. Let f: a b Real numbers be a continuous function with a b and fafb According to the intermediate value theorem, f has at least one root in a b
The bisection method works as follows:
Set L a R b
If the condition fL fR is not met, terminate. Otherwise:
Test whether R L TOL, where TOL is user tolerance eg TOL If yes, there is a root in L R; otherwise,
Continue with subintervals LLR and LR R following step
Write a recursive function
void bisectdouble L double R double TOL
implementing the bisection method, and a double function fdouble x returning fx
Test your implementation with various functions and intervals, outputting the intervals containing roots and the function values at the midpoint.
For instance, running with fx xxx and L R might produce output like:
"A root of f lies in ee fLRe
For fx sinx you might get output similar to:
"A root of f lies in ee fLRe
"A root of f lies in ee fLRe
"A root of f lies in ee fLRe
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
