minterpy.interpolation#

A top-level module with interfaces to conveniently create interpolants.

The main purpose of Minterpy is to interpolate given functions provided as Python Callables. This top-level module provides a convenient function named interpolate, which outputs a Callable of the type Interpolant. This represents the given function as a multidimensional (Newton) polynomial.

Moreover, it is also possible to construct an Interpolator instance. This object precomputes and caches all the necessary ingredients for the interpolation of any functions.

Function / Class

Description

interpolate

Interpolate a given function

Interpolant

Class that represents an interpolated function

Interpolator

Class that represents interpolators for given functions

class minterpy.interpolation.Interpolator(spatial_dimension, poly_degree, lp_degree)[source]#

The construction class for interpolation.

Data type which contains all relevant parts for interpolation and caches them.

Parameters:
  • spatial_dimension (int)

  • poly_degree (int)

  • lp_degree (int)

spatial_dimension#
Type:

dimension of the domain space.

poly_degree#
Type:

degree of the interpolation polynomials

lp_degree#
Type:

degree of the \(l_p\) norm used to determine the poly_degree.

multi_index#
Type:

lexicographically complete multi index set build from (spatial_dimension, poly_degree, lp_degree).

grid#
Type:

Grid instance build from multi_index.

class minterpy.interpolation.Interpolant(fct, interpolator)[source]#

Data type representing the result of an interpolation.

Instances of this class can be used as functions, which interpolate a given function. Users who do not want to learn anything about neither polynomial interpolation nor bases in multivariate polynomial bases may use the instances of this class just as an interpolative representant of their function, which they can evaluate. (Other properties are conceivable too)

Parameters:
fct#
Type:

Function to be interpolated. Needs to be (numpy) universal function which shall be interpolated. If arr is an np.ndarray with shape arr.shape == (N,spatial_dimension), the signature needs to be fct(arr) -> res, where res is an np.ndarray with shape (N,).

interpolator#
Type:

Instance of Interpolator, which represents the interpolation scheme to be used.

classmethod from_degree(fct, spatial_dimension, poly_degree, lp_degree)[source]#

Custom constructor of an interpolant using dimensionality and degree parameter.

Parameters:
  • fct (Callable) – Function to be interpolated. Needs to be (numpy) universal function which shall be interpolated. If arr is an np.ndarray with shape arr.shape == (N,spatial_dimension), the signature needs to be fct(arr) -> res, where res is an np.ndarray with shape (N,).

  • spatial_dimension (int) – dimension of the domain space.

  • poly_degree (int) – degree of the interpolation polynomials

  • lp_degree (int) – degree of the \(l_p\) norm used to determine the poly_degree.

Returns:

The interpolant of fct using the default interpolator build from (spatial_dimension, poly_degree, lp_degree).

Return type:

Interpolant

property spatial_dimension#

Dimension of the domain space the interpolation polynomial lives on.

This is the propagated attribute from self.interpolator.

Return type:

int

property poly_degree#

Degree of the interpolation polynomial.

This is the propagated attribute from self.interpolator.

Return type:

int

property lp_degree#

Degree of the \(l_p\) norm.

This is the propagated attribute from self.interpolator.

Return type:

int

property lagrange_coeffs#

Return the Lagrange coefficients of the interpolating polynomial.

to_newton()[source]#

Return the interpolant as a polynomial in the Newton basis.

to_lagrange()[source]#

Return the interpolant as a polynomial in the Lagrange basis.

to_canonical()[source]#

Return the interpolant as a polynomial in the canonical basis.

to_chebyshev()[source]#

Return the interpolant as a polynomial in the Chebyshev basis.

minterpy.interpolation.interpolate(fct, spatial_dimension, poly_degree, lp_degree=DEFAULT_LP_DEG)[source]#

Interpolate a given function.

Return an interpolant, which represents the given function on the domain \([-1, 1]^d\), where \(d\) is the dimension of the domain space.

Parameters:
  • fct (Callable) – Function to be interpolated. Needs to be (numpy) universal function which shall be interpolated. If arr is an np.ndarray with shape arr.shape == (N,spatial_dimension), the signature needs to be fct(arr) -> res, where res is an np.ndarray with shape (N,).

  • spatial_dimension (int) – dimension of the domain space.

  • poly_degree (int) – degree of the interpolation polynomials

  • lp_degree (int) – degree of the \(l_p\) norm used to determine the poly_degree.

Returns:

The interpolant of fct using the default interpolator build from (spatial_dimension, poly_degree, lp_degree).

Return type:

Interpolant