Jump to content

Bisection method

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by LaundryPizza03 (talk | contribs) at 05:25, 15 October 2025 (Testing: WP:NOTGUIDE). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
A few steps of the bisection method applied over the starting range [a1;b1]. The bigger red dot is the root of the function.

In mathematics, the bisection method is a root-finding method that applies to any continuous function for which one knows two values with opposite signs. The method consists of repeatedly bisecting the interval defined by these values, then selecting the subinterval in which the function changes sign, which therefore must contain a root. It is a very simple and robust method, but it is also relatively slow. Because of this, it is often used to obtain a rough approximation to a solution which is then used as a starting point for more rapidly converging methods.[1] The method is also called the interval halving method,[2] the binary search method,[3] or the dichotomy method.[4]

For polynomials, more elaborate methods exist for testing the existence of a root in an interval (Descartes' rule of signs, Sturm's theorem, Budan's theorem). They allow extending the bisection method into efficient algorithms for finding all real roots of a polynomial; see Real-root isolation.

The method

The method is applicable for numerically solving the equation for the real variable , where is a continuous function defined on an interval and where and have opposite signs. In this case and are said to bracket a root since, by the intermediate value theorem, the continuous function must have at least one root in the interval .

At each step the method divides the interval in two parts/halves by computing the midpoint of the interval and the value of the function at that point. If itself is a root then the process has succeeded and stops. Otherwise, there are now only two possibilities: either and have opposite signs and bracket a root, or and have opposite signs and bracket a root.[5] The method selects the subinterval that is guaranteed to be a bracket as the new interval to be used in the next step. In this way an interval that contains a zero of is reduced in width by 50% at each step. The process is continued until the interval is sufficiently small.

Explicitly, if then may be taken as the solution and the process stops.

Otherwise, if and have the same signs,

  • then the method sets ,
  • else the method sets .

In both cases, the new and have opposite signs, so the method may be applied to this smaller interval.[6]

Once the process starts, the signs at the left and right ends of the interval remain the same for all iterations.

Stopping conditions

In order to determine when the iteration should stop, it is necessary to consider various possible stopping conditions with respect to a tolerance (). Burden & Faires state:[7]

we can select a tolerance and generate p1, ..., pN until one of the following conditions is met:

(2.1)
or (2.2)
(2.3)

Unfortunately, difficulties can arise using any of these stopping criteria ... Without additional knowledge about or , Inequality (2.2) is the best stopping criterion to apply because it comes closest to testing relative error.

The objective is to find an approximation, within the tolerance, to the root.

The following shows that (2.3) does not give such an approximation unless .

If is a root of , then and .

This means that (2.3) can be written as

     or
.

Suppose, for the purpose of illustration, the tolerance is . Now take the case in which so that the approximate value is in the interval

The problem is that, for small (i.e. the slope near the root is small), the interval can be quite large - for example, if , the approximation to 0 could be in

Hence, unless the magniitude of the slope near the root is , this condition will not give a useful result - and the slope is unknown until the root is known.

In fact, using involves a logical fallacy. It is obvious that if is sufficiently close to the root that will become less than . That does not mean that, if , is close to the root!

The other two possibilities represent different concepts - for example, the absolute difference says that c and a are the same to decimal places, while the relative difference says that c and a are the same to significant digits[8].

Note the use of for the tolerance. If 2 numbers differ by this amount then, depending on whether absolute differences or relative differences are being used, the numbers have either decimal places or digits in common. The use of a tolerance such as provides no better information.

Iteration process

The input for the method is a continuous function and an interval , such that the function values and are of opposite sign (there is at least one zero crossing within the interval). Each iteration performs these steps:

  1. Calculate , the midpoint of the interval, ;
  2. Calculate the function value at the midpoint, ;
  3. If , return c;
  4. If convergence is satisfactory (that is, is sufficiently small), return ;
  5. Examine the sign of and replace either or with so that there is a zero crossing within the new interval.

Algorithm

import numpy as np


def bisect(f, a, b, tol):
    if a > b:  # Check that the user has the correct order for endpoints.
        a, b = b, a
    fa = f(a)
    fb = f(b)
    i = 0
    if np.sign(fa) == np.sign(fb):  # Check for opposite signs.
        return float("NAN"), i, b - a, "Same sign"
    while True:
        i += 1
        c = (b + a) / 2
        fc = f(c)
        if b - a <= 5e-324:  # Check for min. interval width.
            return 5e-324, i, b - a, "Min sub"
        if fc == 0:  # Return if f(c) evaluates to 0.
            return c, i, b - a, "f(c)=0"
        if b - a <= abs(c) * tol:  # Test for convergence.
            return c, i, b - a, "Tol"
        if np.sign(fa) == np.sign(fc):
            a = c
        else:
            b = c
        if i > 2100:  # See example 3.
            return c, i, b - a, "Max iter"

Note that there is only one function evaluation per iteration.

If the algorithm returns before tolerance is reached, it is possible to determine the number of significant figures that are returned.

If, after iterations, is satisfied, then digits have been returned.

So can be solved - from which is the number of digits returned.

def compute_sig_digits(width, c):
    if width == 0 or c == 0:
        return 0
    ratio = (5 * abs(c)) / width
    return max(0, int(math.floor(math.log10(ratio))))

Generalization to higher dimensions

The bisection method has been generalized to multi-dimensional functions. Such methods are called generalized bisection methods.[9][10]

Methods based on degree computation

Some of these methods are based on computing the topological degree.[11]

Characteristic bisection method

The characteristic bisection method uses only the signs of a function in different points. Lef f be a function from Rd to Rd, for some integer d ≥ 2. A characteristic polyhedron[12] (also called an admissible polygon)[13] of f is a polyhedron in Rd, having 2d vertices, such that in each vertex v, the combination of signs of f(v) is unique. For example, for d=2, a characteristic polyhedron of f is a quadrilateral with vertices (say) A,B,C,D, such that:

  • Sign f(A) = (-,-), that is, f1(A)<0, f2(A)<0.
  • Sign f(B) = (-,+), that is, f1(B)<0, f2(B)>0.
  • Sign f(C) = (+,-), that is, f1(C)>0, f2(C)<0.
  • Sign f(D) = (+,+), that is, f1(D)>0, f2(D)>0.

A proper edge of a characteristic polygon is a edge between a pair of vertices, such that the sign vector differs by only a single sign. In the above example, the proper edges of the characteristic quadrilateral are AB, AC, BD and CD. A diagonal is a pair of vertices, such that the sign vector differs by all d signs. In the above example, the diagonals are AD and BC.

At each iteration, the algorithm picks a proper edge of the polyhedron (say, A--B), and computes the signs of f in its mid-point (say, M). Then it proceeds as follows:

  • If Sign f(M) = Sign(A), then A is replaced by M, and we get a smaller characteristic polyhedron.
  • If Sign f(M) = Sign(B), then B is replaced by M, and we get a smaller characteristic polyhedron.
  • Else, we pick a new proper edge and try again.

Suppose the diameter (= length of longest proper edge) of the original characteristic polyhedron is . Then, at least bisections of edges are required so that the diameter of the remaining polygon will be at most .[13]: 11, Lemma.4.7 

See also

References

  1. ^ Burden & Faires 2016, p. 51
  2. ^ "Interval Halving (Bisection)". Archived from the original on 2013-05-19. Retrieved 2013-11-07.
  3. ^ Burden & Faires 2016, p. 48
  4. ^ "Dichotomy method - Encyclopedia of Mathematics". www.encyclopediaofmath.org. Retrieved 2015-12-21.
  5. ^ If the function has the same sign at the endpoints of an interval, the endpoints may or may not bracket roots of the function.
  6. ^ Burden & Faires 2016, p. 48
  7. ^ Burden & Faires 2016, p. 50
  8. ^ Burden & Faires 2016, p. 18
  9. ^ Mourrain, B.; Vrahatis, M. N.; Yakoubsohn, J. C. (2002-06-01). "On the Complexity of Isolating Real Roots and Computing with Certainty the Topological Degree". Journal of Complexity. 18 (2): 612–640. doi:10.1006/jcom.2001.0636. ISSN 0885-064X.
  10. ^ Vrahatis, Michael N. (2020). Sergeyev, Yaroslav D.; Kvasov, Dmitri E. (eds.). "Generalizations of the Intermediate Value Theorem for Approximating Fixed Points and Zeros of Continuous Functions". Numerical Computations: Theory and Algorithms. Cham: Springer International Publishing: 223–238. doi:10.1007/978-3-030-40616-5_17. ISBN 978-3-030-40616-5.
  11. ^ Kearfott, Baker (1979-06-01). "An efficient degree-computation method for a generalized method of bisection". Numerische Mathematik. 32 (2): 109–127. doi:10.1007/BF01404868. ISSN 0945-3245.
  12. ^ Vrahatis, Michael N. (1995-06-01). "An Efficient Method for Locating and Computing Periodic Orbits of Nonlinear Mappings". Journal of Computational Physics. 119 (1): 105–119. doi:10.1006/jcph.1995.1119. ISSN 0021-9991.
  13. ^ a b Vrahatis, M. N.; Iordanidis, K. I. (1986-03-01). "A rapid Generalized Method of Bisection for solving Systems of Non-linear Equations". Numerische Mathematik. 49 (2): 123–138. doi:10.1007/BF01389620. ISSN 0945-3245.

Further reading