I'm writing a small program to resolve functions using bisection method. I want to test the case when the method finds 2 roots, but I can't find examples.

Can anyone give me an example of a function that when resoved using bisection method gives 2 roots?

My only request is that when evaluated, the function does not evaluate 0 (because f(a)*f(b) using 0 will give 0).


  • 3
    $\begingroup$ Usually the bisection method is written so that it only finds one root at a time between $a$ and $b$. Maybe you can modify your method so that after finding one root, it changes the endpoints $a$ and $b$ to look for another root? $\endgroup$
    – badjr
    Commented Apr 1, 2013 at 0:10
  • $\begingroup$ I am confused about what you mean. Are you looking for a $f(x) = ax^2 + bx + c$ with two unique roots or two identical roots or something else? $\endgroup$
    – Amzoti
    Commented Apr 1, 2013 at 0:11
  • $\begingroup$ @deezy: I need to find 2 roots. It's mandatory for my program. $\endgroup$
    – Ashir
    Commented Apr 1, 2013 at 0:15
  • 1
    $\begingroup$ @Amzoti: Any function wich gives 2 roots it's ok. f(x)=(x-1)(x-2) gives me 2 roots (1 and 2), but as I say I don't want to evaluate 0 (f(x)=(x-1)(x-2) evaluates on 0 and 3). $\endgroup$
    – Ashir
    Commented Apr 1, 2013 at 0:18

1 Answer 1


If you evaluate $f(x)$ and get zero, you have found a root. Bisection should report it and move on to the next stage. Consider a function like $f(x)=(x-1)(x-2)$. Somehow you have to find the interval $(a,2)$ where the function is negative. Now you take one point outside $(1,2)$ and one point inside it as your starting points. Bisection will converge on $1$ or $2$ (whichever is in the interval you start with). Say you find $1$. In theory, you can now consider $\frac {f(x)}{x-1}$ and if you can find points with opposite signs you can use bisection again to find the root of that. The problem is that maybe you don't find $1$ exactly, so your new function will not be exactly $g(x)=x-2$, but it will be close.

  • $\begingroup$ I don't have problems with functions getting 0, after all that's the point in bisection method. My problem is, if I follow step one (f(a)*f(b)<0) most of the time my program can't find a root in that interval. For example link f(x)=x^2-x-3=0 will give me 2 roots: x = ~~ -1.3027 and ~~ 2.3027, so, the roots are between -2 and 3, but f(-2)*f(3) will return 9, so it will fail step one of the method because it's not < than 0 (f(a) it's possitive and f(b) is also possitive, when they should have different signs)... $\endgroup$
    – Ashir
    Commented Apr 1, 2013 at 1:05
  • $\begingroup$ You have to bracket the roots first for bisect ion. That is, you need to find $a,b$ with $f(a)f(b) \lt 0$ otherwise you don't know there is a root to find at all. Think about$ x^2-x+3$. If you start with $-2,3$ there are no roots inside. $\endgroup$ Commented Apr 1, 2013 at 1:33
  • 1
    $\begingroup$ Before you can start the Bisection Method, you have to detect a sign change. After that, the Method will find one root. If Bisection is to be used for another root in the interval, a sign change will have to be detected in an interval thAt was discarded in the first run. $\endgroup$ Commented Aug 22, 2013 at 17:23

Not the answer you're looking for? Browse other questions tagged .