I'm writing an interpolation method without using a library functions which does it directly. The signature of the function is:
def interpolate(self, f: callable, a: float, b: float, n: int) -> callable:
"""
Parameters
----------
f : callable. it is the given function
a : float
beginning of the interpolation range.
b : float
end of the interpolation range.
n : int
maximal number of points to use.
Returns
-------
The interpolating function.
"""
Right now my implementation is straight forward "Lagrange Interpolation" as explained here: https://www.codesansar.com/numerical-methods/python-program-lagrange-interpolation-method.htm
However, this kind of implementation is O(n^2) and I'm looking for a more efficient solution which runs in O(n).
(Maybe Bézier Curves can help here somehow?)