using MathNet.Numerics.Interpolation;
double[] x = { 0, 25, 50, 75, 100 };
double[] y = { 100, 50, 40, 45, 50 };
double[] checkValue = { 50, 40 };
PrintInterpolatedValues(CubicSpline.InterpolateAkimaSorted(x, y), "CubicSpline.InterpolateAkimaSorted");
PrintInterpolatedValues(CubicSpline.InterpolateNaturalSorted(x, y), "CubicSpline.InterpolateNaturalSorted");
PrintInterpolatedValues(CubicSpline.InterpolatePchipSorted(x, y), "CubicSpline.InterpolatePchipSorted");
PrintInterpolatedValues(Interpolate.CubicSpline(x, y), "Interpolate.CubicSpline");
PrintInterpolatedValues(Interpolate.CubicSplineRobust(x, y), "Interpolate.CubicSplineRobust");
PrintInterpolatedValues(Interpolate.CubicSplineMonotone(x, y), "Interpolate.CubicSplineMonotone");
PrintInterpolatedValues(Interpolate.Linear(x, y), "Interpolate.Linear");
PrintInterpolatedValues(Interpolate.LogLinear(x, y), "Interpolate.LogLinear");
PrintInterpolatedValues(Interpolate.Polynomial(x, y), "Interpolate.Polynomial");
PrintInterpolatedValues(Interpolate.PolynomialEquidistant(x, y), "Interpolate.PolynomialEquidistant");
void PrintInterpolatedValues(IInterpolation interpolation, string name)
for (int xValue = 0; xValue <= 100; xValue += 10)
double interpolatedValue = interpolation.Interpolate(xValue);
Console.WriteLine($"{interpolatedValue:F3}");
if (interpolation.Interpolate(checkValue[0]) == checkValue[1])
Console.WriteLine("Interpolation hits the check value");
Console.WriteLine("Interpolation does not hit the check value");