@Van1tyC4se As you pointed out Bisection does have trouble with flat functions. There are too many points close to the actual root it has a hard time discerning it. Using the interval tolerance approach you described is a common way to avoid this scenario. Adding the additional condition is not a big deal in the long run because Bisection takes linear time. I would check both.
Hello. I see that you (like most people) check with tolerance with something like:
if f(c)<error
and this creates a problem with flat functions.
What I did was check like this:
if (b-a)<tolerance then
root = (a+b)/2
which means that once I have bracketed the root into a sufficiently small interval I just pick the midpoint to be my answer. This usually takes more steps but seems to work fine with flat functions. I even checked with (x-5)^11 :). Any thoughts?
thanks alot .
TheMinisterzuhair 1 month ago
@Van1tyC4se As you pointed out Bisection does have trouble with flat functions. There are too many points close to the actual root it has a hard time discerning it. Using the interval tolerance approach you described is a common way to avoid this scenario. Adding the additional condition is not a big deal in the long run because Bisection takes linear time. I would check both.
c=(b-a)/2
while abs(f(c))>e and (b-a)>tol
{
if (f(c)*f(a))<=0 //dif signs b=c
else a=c
c=(b-a)/2
}
root=c
oscarsveliz 1 month ago
Hello. I see that you (like most people) check with tolerance with something like:
if f(c)<error
and this creates a problem with flat functions.
What I did was check like this:
if (b-a)<tolerance then
root = (a+b)/2
which means that once I have bracketed the root into a sufficiently small interval I just pick the midpoint to be my answer. This usually takes more steps but seems to work fine with flat functions. I even checked with (x-5)^11 :). Any thoughts?
Van1tyC4se 1 month ago
very clear Thanks
TheMpax2 7 months ago