Skip to main content

Section 3.6 The root_scalar SciPy command

SciPy defines its own command root_scalar to find zeros of functions in one variable.

This command implements many numerical root-finding methods, including the three we presented in this chapter (see the code below). Among the implemented methods not covered here, we mention the following:
  1. The Brent's method, a hybrid root-finding algorithm combining the bisection method, the secant method and inverse quadratic interpolation, having the reliability of the bisection method and a speed comparable with that of the Newton's method.
  2. The Halley's, which is the Newton method applied to the function \(f(x)/\sqrt{|f'(x)|}\text{.}\) This method needs in input \(f''(x)\) and converges cubicly to the root.
Below we show how to use this command in simple cases.