{ } Raw JSON

bundles / scipy latest / scipy / interpolate / _bary_rational / FloaterHormannInterpolator

class

scipy.interpolate._bary_rational:FloaterHormannInterpolator

source: /scipy/interpolate/_bary_rational.py :630

Signature

class   FloaterHormannInterpolator ( points values * d = 3 axis = 0 )

Members

Summary

Floater-Hormann barycentric rational interpolator (C∞ smooth on real axis).

Extended Summary

As described in [1], the method of Floater and Hormann computes weights for a barycentric rational interpolant with no poles on the real axis.

Parameters

x : 1D array_like, shape (n,)

1-D array containing values of the independent variable. Values may be real or complex but must be finite.

y : array_like, shape (n, ...)

Array containing values of the dependent variable. Infinite and NaN values of y and corresponding values of x will be discarded.

d : int, default: 3

Integer satisfying 0 <= d < n. Floater-Hormann interpolation blends n - d polynomials of degree d together; for d = n - 1, this is equivalent to polynomial interpolation.

axis : int, default: 0

Axis of y corresponding to x.

Attributes

weights : array

Weights of the barycentric approximation.

Notes

The Floater-Hormann interpolant is a rational function that interpolates the data with approximation order . The rational function blends n - d polynomials of degree d together to produce a rational interpolant that contains no poles on the real axis, unlike AAA. The interpolant is given by

where is an interpolating polynomial of at most degree d through the points , and are blending functions defined by

When d = n - 1 this reduces to polynomial interpolation.

Due to its stability, the following barycentric representation of the above equation is used for computation

where the weights are computed as

Examples

Here we compare the method against polynomial interpolation for an example where the polynomial interpolation fails due to Runge's phenomenon.
import numpy as np
from scipy.interpolate import (FloaterHormannInterpolator,
                               BarycentricInterpolator)
def f(x):
    return 1/(1 + x**2)
x = np.linspace(-5, 5, num=15)
r = FloaterHormannInterpolator(x, f(x))
p = BarycentricInterpolator(x, f(x))
xx = np.linspace(-5, 5, num=1000)
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(xx, f(xx), label="f(x)")
ax.plot(xx, r(xx), "--", label="Floater-Hormann")
ax.plot(xx, p(xx), "--", label="Polynomial")
ax.legend()
plt.show()
fig-9ffea95db334010d.png

See also

AAA

Barycentric rational approximation of real and complex functions.

pade

Padé approximation.

Aliases

  • scipy.interpolate.FloaterHormannInterpolator

Referenced by