gftool.hermpade.hermite2
- gftool.hermpade.hermite2(an, p_deg: int, q_deg: int, r_deg: int) Tuple[Polynomial, Polynomial, Polynomial] [source]
Return the polynomials p, q, r for the quadratic Hermite-Padé approximant.
The polynomials fulfill the equation
\[p(x) + q(x) f(x) + r(x) f^2(x) = 𝒪(x^{N_p + N_q + N_r + 2})\]where \(f(x)\) is the function with Taylor coefficients an, and \(N_x\) are the degrees of the polynomials. The approximant has two branches
\[F^±(z) = [-q(z) ± \sqrt{q^2(z) - 4p(z)r(z)}] / 2r(z)\]- Parameters:
- an(L,) array_like
Taylor series coefficients representing polynomial of order
L-1
.- p_deg, q_deg, r_degint
The order of the polynomials of the quadratic Hermite-Padé approximant. The sum must be at most
p_deg + q_deg + r_deg + 2 <= L
.
- Returns:
- p, q, rPolynom
The polynomials p, q, and r building the quadratic Hermite-Padé approximant.
See also
Hermite2
High-level interface, guessing the correct branch.
Examples
The quadratic Hermite-Padé approximant can reproduce the square root
f(z) = (1 + z)**(1/2)
:>>> from scipy.special import binom >>> an = binom(1/2, np.arange(5+5+5+2)) # Taylor of (1+x)**(1/2) >>> x = np.linspace(-3, 3, num=500) >>> fx = np.emath.power(1+x, 1/2)
>>> p, q, r = gt.hermpade.hermite2(an, 5, 5, 5) >>> px, qx, rx = p(x), q(x), r(x) >>> pos_branch = (-qx + np.emath.sqrt(qx**2 - 4*px*rx)) / (2*rx)
>>> import matplotlib.pyplot as plt >>> __ = plt.plot(x, fx.real, label='exact', color='black') >>> __ = plt.plot(x, fx.imag, '--', color='black') >>> __ = plt.plot(x, pos_branch.real, '--', label='Herm2', color='C1') >>> __ = plt.plot(x, pos_branch.imag, ':', color='C1') >>> plt.show()