public void TestInterpolationMethod_CubicSpline_BoundarySecondDerivativeFixed()
        {
            double[] t = new double[] { -2.0, -1.0, 0.0, 1.0, 2.0 };
            double[] x = new double[] { 1.0, 2.0, -1.0, 0.0, 1.0 };

            IInterpolationMethod method = Interpolation.CreateCubicSpline(t, x, SplineBoundaryCondition.SecondDerivative, -5.0, SplineBoundaryCondition.SecondDerivative, -1.0);

            Assert.That(method, Is.TypeOf(typeof(CubicSplineInterpolation)), "Type");

            for (int i = 0; i < t.Length; i++)
            {
                // verify the interpolated values exactly at the sample points.
                Assert.That(method.Interpolate(t[i]), Is.EqualTo(x[i]), "A Exact Point " + i.ToString());
            }

            // Maple: "with(CurveFitting);"
            // Maple: "evalf(subs({x=-2.4},Spline([[-2,1],[-1,2],[0,-1],[1,0],[2,1]], x, degree=3, endpoints=Matrix(2,13,{(1,3)=1,(1,13)=-5,(2,10)=1,(2,13)=-1}))),20);"
            Assert.That(method.Interpolate(-2.4), NumericIs.AlmostEqualTo(-.8999999999999999993, 1e-15), "A -2.4");
            Assert.That(method.Interpolate(-0.9), NumericIs.AlmostEqualTo(1.7590357142857142857, 1e-15), "A -0.9");
            Assert.That(method.Interpolate(-0.5), NumericIs.AlmostEqualTo(.41517857142857142854, 1e-15), "A -0.5");
            Assert.That(method.Interpolate(-0.1), NumericIs.AlmostEqualTo(-.82010714285714285714, 1e-15), "A -0.1");
            Assert.That(method.Interpolate(0.1), NumericIs.AlmostEqualTo(-1.1026071428571428572, 1e-15), "A 0.1");
            Assert.That(method.Interpolate(0.4), NumericIs.AlmostEqualTo(-1.0211428571428571429, 1e-15), "A 0.4");
            Assert.That(method.Interpolate(1.2), NumericIs.AlmostEqualTo(.31771428571428571421, 1e-15), "A 1.2");
            Assert.That(method.Interpolate(10.0), NumericIs.AlmostEqualTo((double)39, 1e-14), "A 10.0");
            Assert.That(method.Interpolate(-10.0), NumericIs.AlmostEqualTo((double)(-37), 1e-14), "A -10.0");
        }
        public void TestInterpolationMethod_CubicSpline_BoundaryFirstDerivativeFixed()
        {
            double[] t = new double[] { -2.0, -1.0, 0.0, 1.0, 2.0 };
            double[] x = new double[] { 1.0, 2.0, -1.0, 0.0, 1.0 };

            IInterpolationMethod method = Interpolation.CreateCubicSpline(t, x, SplineBoundaryCondition.FirstDerivative, 1.0, SplineBoundaryCondition.FirstDerivative, -1.0);

            Assert.That(method, Is.TypeOf(typeof(CubicSplineInterpolation)), "Type");

            for (int i = 0; i < t.Length; i++)
            {
                // verify the interpolated values exactly at the sample points.
                Assert.That(method.Interpolate(t[i]), Is.EqualTo(x[i]), "A Exact Point " + i.ToString());
            }

            // Maple: "with(CurveFitting);"
            // Maple: "evalf(subs({x=-2.4},Spline([[-2,1],[-1,2],[0,-1],[1,0],[2,1]], x, degree=3, endpoints=[1,-1])),20);"
            Assert.That(method.Interpolate(-2.4), NumericIs.AlmostEqualTo(1.120000000000000001, 1e-15), "A -2.4");
            Assert.That(method.Interpolate(-0.9), NumericIs.AlmostEqualTo(1.8243928571428571428, 1e-15), "A -0.9");
            Assert.That(method.Interpolate(-0.5), NumericIs.AlmostEqualTo(.54910714285714285715, 1e-15), "A -0.5");
            Assert.That(method.Interpolate(-0.1), NumericIs.AlmostEqualTo(-.78903571428571428572, 1e-15), "A -0.1");
            Assert.That(method.Interpolate(0.1), NumericIs.AlmostEqualTo(-1.1304642857142857143, 1e-15), "A 0.1");
            Assert.That(method.Interpolate(0.4), NumericIs.AlmostEqualTo(-1.1040000000000000000, 1e-15), "A 0.4");
            Assert.That(method.Interpolate(1.2), NumericIs.AlmostEqualTo(.4148571428571428571, 1e-15), "A 1.2");
            Assert.That(method.Interpolate(10.0), NumericIs.AlmostEqualTo(-608.14285714285714286, 1e-15), "A 10.0");
            Assert.That(method.Interpolate(-10.0), NumericIs.AlmostEqualTo(1330.1428571428571429, 1e-15), "A -10.0");
        }