If I am finding the roots of a polynomial using the bisection method, and in some cases depending on the polynomial the roots might be negative or they may be positive.
I understand I can determine if the roots are going to be negative or positive, based on the result of evaluating the polynomial... however I am unsure what I would use as x.
Can anyone give any insight here?
The fact that the roots can be negative or positive has nothing to do with the bisection method. The existence of a root can be proved using the intermediate value theorem from calculus.
So all you have to do is find points
x1
andx2
such thaty(x1)
is negative andy(x2)
is positive. Then you know from the IVT that there is a root betweenx1
andx2
. You do that by doing a binary search on that interval. Ify(x3) = y((x1+x2)/2)
is negative, then you repeat the bisection search on the interval[x3,x2]
. Otherwise if it's positive, then search on the interval[x1,x3]
.It doesn't matter whether the root is negative or positive. I'm not sure if that answers your question, but I hope that helps you understand the algorithm.