The function bisectEW7 should first check if either xL or xR satisfies the stopping criterion specified by fTol. If one (or both) satisfy the criterion, then that value (or the one that makes f(x) smallest) should be returned as the root, and rHist should be a 0 x 1 empty array.
Hello,
I am trying to check if the left end point (xL) and right end point (xR) as inputs to a function handle are roots within the tolerance I set (fTol). I am trying to set up a part of code that will check if xR or xL are zeros to the function.
The problem I am running into is that I want to say if either one is a zero, then to find the one that minimizes fHan(x), then call that r.
Here is my code so far
if (fHan(xL) <= fTol) || (fHan(xR) <= fTol) rPossible = [abs(fHan(xL)) abs(fHan(xR))] rSmallest = min(rPossible); r = rHist = cell(0,1);
if I do rPossible, I will get f(xR) and f(xL). rSmallest = min(rPossible) will give me the smallest of those two (i.e. closest to zero). Now what I want r to do is store either xL or xR, whichever makes the function closest to zero. How do I extract xL or xR from the handle?
Thanks
Best Answer