MCPcopy Create free account
hub / github.com/numpy/numpy / interpolate

Method interpolate

numpy/polynomial/chebyshev.py:2038–2077  ·  view source on GitHub ↗

Interpolate a function at the Chebyshev points of the first kind. Returns the series that interpolates `func` at the Chebyshev points of the first kind scaled and shifted to the `domain`. The resulting series tends to a minmax approximation of `func` when the function is

(cls, func, deg, domain=None, args=())

Source from the content-addressed store, hash-verified

2036
2037 @classmethod
2038 def interpolate(cls, func, deg, domain=None, args=()):
2039 """Interpolate a function at the Chebyshev points of the first kind.
2040
2041 Returns the series that interpolates `func` at the Chebyshev points of
2042 the first kind scaled and shifted to the `domain`. The resulting series
2043 tends to a minmax approximation of `func` when the function is
2044 continuous in the domain.
2045
2046 .. versionadded:: 1.14.0
2047
2048 Parameters
2049 ----------
2050 func : function
2051 The function to be interpolated. It must be a function of a single
2052 variable of the form ``f(x, a, b, c...)``, where ``a, b, c...`` are
2053 extra arguments passed in the `args` parameter.
2054 deg : int
2055 Degree of the interpolating polynomial.
2056 domain : {None, [beg, end]}, optional
2057 Domain over which `func` is interpolated. The default is None, in
2058 which case the domain is [-1, 1].
2059 args : tuple, optional
2060 Extra arguments to be used in the function call. Default is no
2061 extra arguments.
2062
2063 Returns
2064 -------
2065 polynomial : Chebyshev instance
2066 Interpolating Chebyshev instance.
2067
2068 Notes
2069 -----
2070 See `numpy.polynomial.chebfromfunction` for more details.
2071
2072 """
2073 if domain is None:
2074 domain = cls.domain
2075 xfunc = lambda x: func(pu.mapdomain(x, cls.window, domain), *args)
2076 coef = chebinterpolate(xfunc, deg)
2077 return cls(coef, domain=domain)
2078
2079 # Virtual properties
2080 domain = np.array(chebdomain)

Callers 2

test_dimensionsMethod · 0.45
test_approximationMethod · 0.45

Calls 2

chebinterpolateFunction · 0.85
funcFunction · 0.50

Tested by 2

test_dimensionsMethod · 0.36
test_approximationMethod · 0.36