pooltool.ptmath.roots.core

Overview

Function

get_real_positive_smallest_roots(roots, abs_or_rel_cutoff, rtol, atol)

Returns the smallest postive and real root for each set of roots.

Functions

pooltool.ptmath.roots.core.get_real_positive_smallest_roots(roots: numpy.typing.NDArray[numpy.complex128], abs_or_rel_cutoff: float = 0.001, rtol: float = 0.001, atol: float = 1e-09) numpy.typing.NDArray[numpy.float64][source]

Returns the smallest postive and real root for each set of roots.

Parameters:
  • roots (numpy.typing.NDArray[numpy.complex128]) -- A mxn array of polynomial root solutions, where m is the number of equations and n is the order of the polynomial.

  • abs_or_rel_cutoff (float) -- The criteria for a root being real depends on the magnitude of its real component. If it’s large, we require the imaginary component to be less than atol in absolute terms. But when the real component is small, we require the imaginary component be less than a fraction, rtol, of the real component. abs_or_rel_cutoff defines a threshold for the magnitude of the real component, above which atol is used and below which rtol is used.

  • atol (float) -- A root r (with abs(r.real) >= abs_or_rel_cutoff) is considered real if abs(r.imag) < atol.

  • rtol (float) -- A root r (with abs(r.real) < abs_or_rel_cutoff) is considered real if abs(r.imag) / abs(r.real) < rtol. And in the special case when r.real == 0, the root is considered real if r.imag == 0, too.

Returns:

An array of shape m. Each value is the smallest root that is real and positive. If no such root exists (e.g. all roots are complex), then np.inf is used.

Return type:

numpy.typing.NDArray[numpy.float64]