public void TestInterpolationMethod_Chebyshev2BarycentricPolynomial() { double[] x = new double[] { 0.0, 3.0, 2.5, 1.0, 3.0 }; IInterpolationMethod method = Interpolation.CreateOnChebyshevSecondKindPoints(0.0, 4.0, x); Assert.That(method, Is.TypeOf(typeof(ChebyshevSecondKindPolynomialInterpolation)), "Type"); double[] t = Interpolation.GenerateChebyshevSecondKindSamplePoints(0.0, 4.0, 5); for (int i = 0; i < 4; i++) { // verify the generated chebyshev2 points double tt = 2.0 + (2.0 * Math.Cos(Math.PI * i * 0.25)); 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(0*Pi/4)+2,0],[2*cos(1*Pi/4)+2,3],[2*cos(2*Pi/4)+2,2.5],[2*cos(3*Pi/4)+2,1],[2*cos(4*Pi/4)+2,3]]), x)),20);" Assert.That(method.Interpolate(0.1), NumericIs.AlmostEqualTo(2.4826419375703841423, 1e-14), "A 0.1"); Assert.That(method.Interpolate(0.4), NumericIs.AlmostEqualTo(1.3814129880730972522, 1e-14), "A 0.4"); Assert.That(method.Interpolate(1.1), NumericIs.AlmostEqualTo(.8808232156067110292, 1e-15), "A 1.1"); Assert.That(method.Interpolate(3.2), NumericIs.AlmostEqualTo(3.478116015902536997, 1e-15), "A 3.2"); Assert.That(method.Interpolate(4.5), NumericIs.AlmostEqualTo(-5.035612822087164912, 1e-15), "A 4.5"); Assert.That(method.Interpolate(10.0), NumericIs.AlmostEqualTo(-369.20562748477140583, 1e-13), "A 10.0"); Assert.That(method.Interpolate(-10.0), NumericIs.AlmostEqualTo(1199.4696961966999204, 1e-12), "A -10.0"); }