public void TestInterpolationMethod_Chebyshev1BarycentricPolynomial() { double[] x = new double[] { 0.0, 3.0, 2.5, 1.0, 3.0 }; IInterpolationMethod method = Interpolation.CreateOnChebyshevFirstKindPoints(0.0, 4.0, x); Assert.That(method, Is.TypeOf(typeof(ChebyshevFirstKindPolynomialInterpolation)), "Type"); double[] t = Interpolation.GenerateChebyshevFirstKindSamplePoints(0.0, 4.0, 5); for (int i = 0; i < 4; i++) { // verify the generated chebyshev1 points double tt = 2.0 + (2.0 * Math.Cos(Math.PI * 0.1 * ((2 * i) + 1))); Assert.That(tt, NumericIs.AlmostEqualTo(t[i]), "Point " + i.ToString()); // verify the interpolated values exactly at the sample points. Assert.That(method.Interpolate(tt), NumericIs.AlmostEqualTo(x[i]), "A Exact Point " + i.ToString()); } // Maple: "with(CurveFitting);" // Maple: "evalf(subs({x=0.1},PolynomialInterpolation(evalf([[2*cos(Pi/10)+2,0],[2*cos(3*Pi/10)+2,3],[2*cos(5*Pi/10)+2,2.5],[2*cos(7*Pi/10)+2,1],[2*cos(9*Pi/10)+2,3]]), x)),20);" Assert.That(method.Interpolate(0.1), NumericIs.AlmostEqualTo(2.9882560375702001608, 1e-15), "A 0.1"); Assert.That(method.Interpolate(0.4), NumericIs.AlmostEqualTo(1.7097090371118968872, 1e-15), "A 0.4"); Assert.That(method.Interpolate(1.1), NumericIs.AlmostEqualTo(1.0462830804302586508, 1e-15), "A 1.1"); Assert.That(method.Interpolate(3.2), NumericIs.AlmostEqualTo(2.951922899377369724, 1e-15), "A 3.2"); Assert.That(method.Interpolate(4.5), NumericIs.AlmostEqualTo(-5.394317844683536750, 1e-15), "A 4.5"); Assert.That(method.Interpolate(10.0), NumericIs.AlmostEqualTo(-228.01438153088988107, 1e-13), "A 10.0"); Assert.That(method.Interpolate(-10.0), NumericIs.AlmostEqualTo(1979.2646653044133954, 1e-12), "A -10.0"); }