qml.transforms.poly_extrapolate

poly_extrapolate(x, y, order)[source]

Extrapolator to \(f(0)\) for polynomial fit.

The polynomial is defined as f(x) = p[0] * x**deg + p[1] * x**(deg-1) + ... + p[deg] such that deg = order + 1. This function is compatible with all interfaces supported by pennylane.

Parameters
  • x (Array) – Data in x

  • y (Array) – Data in y = f(x)

  • order (int) – Order of the polynomial fit

Returns

Extrapolated value at f(0).

Return type

float

Example:

>>> x = np.linspace(1, 10, 5)
>>> y = x**2 + x + 1 + 0.3 * np.random.rand(len(x))
>>> qml.transforms.poly_extrapolate(x, y, 2)
tensor(1.01717601, requires_grad=True)