Code: Select all
Function: Sin(x)
Range: [-pi/4;pi/4]
4-point interpolation (equally spaced points) of function Sin(Sqrt(x))/Sqrt(x)
Test: fast test with 10000 samples (in Range)
AnalyticInt : rel.err:~ 7.7601e-06 @ pos:~ -7.2360e-01 - Piecewise analytic interpolation
BaryInv : rel.err:~ 1.0390e-02 @ pos:~ -7.7952e-01 - Barycentric interpolation with inverse distance weighting
Barylag : rel.err:~ 1.2966e-08 @ pos:~ -3.1796e-01 - Barycentric lagrange interpolation
BulirschStoer : rel.err:~ 3.0480e-08 @ pos:~ 3.1698e-01 - Rational Bulirsch-Stoer interpolation
Cakima : rel.err:~ 9.3585e-07 @ pos:~ 2.7874e-01 - Piecewise cubic Akima interpolation
CBezier : rel.err:~ 6.1144e-05 @ pos:~ 3.2204e-01 - Piecewise cubic Bezier spline interpolation
Chermite : rel.err:~ 1.3788e-06 @ pos:~ -3.3441e-01 - Piecewise cubic Hermite spline interpolation (Finite difference)
Chermite : rel.err:~ 8.5600e-05 @ pos:~ -2.9732e-01 - Piecewise cubic Hermite spline interpolation (Catmull-Rom spline)
Chermite : rel.err:~ 8.5600e-05 @ pos:~ -2.9732e-01 - Piecewise cubic Hermite spline interpolation (Monotone interpolation)
Chermite : rel.err:~ 6.6922e-07 @ pos:~ -7.8529e-01 - Piecewise cubic Hermite spline interpolation (Monotone with Lam harmonic mean)
ConstInt : rel.err:~ 2.2558e-02 @ pos:~ 6.2665e-01 - Piecewise constant interpolation
CosInt : rel.err:~ 4.8498e-03 @ pos:~ 7.6286e-01 - Piecewise cosine interpolation
CSPline : rel.err:~ 6.1144e-05 @ pos:~ 3.2204e-01 - Piecewise cubic spline interpolation
CubicFarrow : rel.err:~ 9.4201e-02 @ pos:~ 5.1166e-01 - Cubic Farrow interpolation
CubiConv : rel.err:~ 1.3788e-06 @ pos:~ -3.3441e-01 - Cubic convolution interpolation
CubInt : rel.err:~ 1.1613e+01 @ pos:~ -7.8540e-01 - Piecewise cubic interpolation (Finite difference)
CubInt : rel.err:~ 1.1498e+01 @ pos:~ -7.8540e-01 - Piecewise cubic interpolation (Catmull-Rom spline)
CubInt : rel.err:~ 1.1498e+01 @ pos:~ -7.8540e-01 - Piecewise cubic interpolation (Monotone interpolation)
CubInt : rel.err:~ 1.1613e+01 @ pos:~ -7.8540e-01 - Piecewise cubic interpolation (Monotone with Lam harmonic mean)
ExpInt : rel.err:~ -9.9120e-05 @ pos:~ 7.8539e-01 - Piecewise exponential interpolation
FloaterHormann : rel.err:~ 1.2966e-08 @ pos:~ 3.1795e-01 - Rational interpolation using the Floater-Hormann Method
FractInt : - self-affine fractal interpolation for specific interpolation points
HermInt : - piecewise Hermite interpolation
HilbInt : rel.err:~ -7.3502e-01 @ pos:~ 7.8539e-01 - Piecewise Hilbert transform interpolation (Rectangular window)
HilbInt : rel.err:~ -9.9586e-01 @ pos:~ 7.8539e-01 - Piecewise Hilbert transform interpolation (Lanczos window)
HilbInt : rel.err:~ -9.5708e-01 @ pos:~ 7.8539e-01 - Piecewise Hilbert transform interpolation (Hamming window)
HilbInt : rel.err:~ -9.6904e-01 @ pos:~ 7.8539e-01 - Piecewise Hilbert transform interpolation (Squared cosine window)
HilbInt : rel.err:~ -8.9266e-01 @ pos:~ 7.8539e-01 - Piecewise Hilbert transform interpolation (Kaiser window (alpha = 3))
HilbInt : rel.err:~ -9.0682e-01 @ pos:~ 7.8539e-01 - Piecewise Hilbert transform interpolation (Blackman window)
Krogh : rel.err:~ -1.0313e-08 @ pos:~ 7.8530e-01 - Interpolation using Krogh algorithm
LagInt : rel.err:~ -1.1928e-06 @ pos:~ 7.8539e-01 - Piecewise Lagrange interpolation
LinInt : rel.err:~ 1.4836e-04 @ pos:~ 6.2766e-01 - Piecewise linear interpolation
MinimaxPoly : - Optimal polynomial via the Remez algorithm
MinimaxRat : - Optimal rational polynomial via the Remez algorithm
MQSpline : rel.err:~ 6.6922e-07 @ pos:~ -7.8529e-01 - Piecewise monotone quadratic spline interpolation (Lam harmonic mean)
MQSpline : rel.err:~ 5.8454e-05 @ pos:~ -3.2521e-01 - Piecewise monotone quadratic spline interpolation (Schumaker estimation)
Neville : rel.err:~ 1.2966e-08 @ pos:~ -3.1795e-01 - Interpolation using Neville's Method
NewtInt : rel.err:~ 1.2966e-08 @ pos:~ 3.1795e-01 - Interpolation of equally-spaced points (Forwards method)
NewtInt : rel.err:~ 1.2969e-08 @ pos:~ -3.1795e-01 - Interpolation of equally-spaced points (Backwards method)
NewtInt : rel.err:~ 1.1149e-02 @ pos:~ -3.6180e-01 - Interpolation of equally-spaced points (Stiring's method)
NewtInt : rel.err:~ 7.4651e-05 @ pos:~ 3.3456e-01 - Interpolation of equally-spaced points (Everett's method)
PolyCof : rel.err:~ 5.0620e-05 @ pos:~ -7.8540e-01 - Non-Vandermonde polynomial interpolation coefficients
QHermite : rel.err:~ 1.4051e-06 @ pos:~ 3.2608e-01 - Piecewise quintic Hermite interpolation (Finite difference)
QHermite : rel.err:~ 1.0433e-04 @ pos:~ 2.9340e-01 - Piecewise quintic Hermite interpolation (Catmull-Rom spline)
QSpline : rel.err:~ 1.8161e-02 @ pos:~ 6.2782e-01 - Piecewise quadratic spline interpolation
RatInt : rel.err:~ -8.1855e-07 @ pos:~ 7.8539e-01 - Simple rational polynomial interpolation
RCHermite : rel.err:~ -1.1989e-04 @ pos:~ 7.8539e-01 - Piecewise rational cubic Hermite spline interpolation
Said : rel.err:~ 1.9109e-01 @ pos:~ 3.4258e-01 - Piecewise Said interpolation (Sinc)
Said : rel.err:~ 1.0942e-01 @ pos:~ 3.0902e-01 - Piecewise Said interpolation (Lanczos, M=2 )
Said : rel.err:~ 1.2912e-01 @ pos:~ 3.1993e-01 - Piecewise Said interpolation (Lanczos, M=3 )
Said : rel.err:~ 1.4596e-01 @ pos:~ -3.3161e-01 - Piecewise Said interpolation (Lanczos, M=4 )
Said : rel.err:~ 1.5936e-01 @ pos:~ -3.3681e-01 - Piecewise Said interpolation (Lanczos, M=5 )
Said : rel.err:~ 9.2656e-02 @ pos:~ -2.9740e-01 - Piecewise Said interpolation (Blackman-Harris, N=6)
Said : rel.err:~ 1.1773e-01 @ pos:~ -3.1600e-01 - Piecewise Said interpolation (Cubic B-Spline)
Said : rel.err:~ 5.1442e-02 @ pos:~ 2.5192e-01 - Piecewise Said interpolation (Mitchell-Netravali, B=C=1/3)
Schwerner : rel.err:~ 3.0480e-08 @ pos:~ -3.1698e-01 - Rational interpolation using the Schneider-Werner Method
SHermite : rel.err:~ 1.4296e-06 @ pos:~ 3.2123e-01 - Piecewise septic Hermite interpolation
SincDInt : rel.err:~ 1.9484e-02 @ pos:~ -3.1358e-01 - Piecewise discrete sinc interpolation
SincInt : rel.err:~ 8.7148e-02 @ pos:~ -2.9989e-01 - Piecewise sinc interpolation
Steffen : rel.err:~ 1.3788e-06 @ pos:~ -3.3441e-01 - Monotonic Steffen interpolation
Stineman : rel.err:~ 1.2843e-06 @ pos:~ -3.3236e-01 - Monotonic Stineman interpolation
Thiele : rel.err:~ -7.3597e-09 @ pos:~ 7.8539e-01 - Rational Thiele interpolation
TrigInt : rel.err:~ -1.6538e-04 @ pos:~ 7.8539e-01 - Piecewise trigonometric interpolation
Tested methods comes from Joe Henning (2022).
Interpolation Utilities (https://www.mathworks.com/matlabcentral/fileexchange/36800-interpolation-utilities), MATLAB Central File Exchange. Retrieved May 9, 2022.
Krogh's algorithm is from scipy library which can be fround from https://programtalk.com/vs2/?source=python/11627/scipy/scipy/
I've found few papers as like these:
Krogh: Efficient Algorithms for Polynomial Interpolation (Semantic Scholar)
Macleod: A comparison of algorithms for polynomial interpolation (Science Direct):
but, as those mathematical equations there are out of my math skills, these are not very helpful for me.
KroghInterpolator (Python implementation) I've bumped to can be found in scipy library (Program Talk) but, I'm not familiar with python language ... and the implementation looks (by my skills) quite complex to implement in C/C++. Managed to found out what's happening there in main-loop but, (A*) there are tasks like initalization, reshaping arrays and axis rolling which I did not got solved and also, how/what those c and Vk arrays acts/holds in in calculations (two dimensional in definition, one dimensional in calculations).
<code snipped deleted>
So, in short, looking a quick path
Q: Which one of Krogh's algorithms they used in scipy implementation?
Q: Any suggestions for A*
Q: Any open source (C/C++/Matlab) Krogh algorithm implementations available?
---
BTW, It looks like (at least) GCC and Clang can handle well some of those calculations involved, as like it does as for an example, in case of Lagrange interpolation:
Desmos 3-point 4-point
Compiler Explorer -
Quick C++ benchmark Clang GCC