Example: The cubic spline interpolant

A cubic spline interpolant to a function is computed. The value of the spline at point 0.25 is printed.
using System;
using Imsl.Math;

public class CsInterpolateEx1
{
    public static void  Main(String[] args)
    {
        int n = 11;
        double[] x = new double[n];
        double[] y = new double[n];
        
        for (int k = 0; k < n; k++)
        {
            x[k] = (double) k / (double) (n - 1);
            y[k] = System.Math.Sin(15.0 * x[k]);
        }
        
        CsInterpolate cs = new CsInterpolate(x, y);
        double csv = cs.Eval(0.25);
        Console.Out.WriteLine("The computed cubic spline value at " + 
                              "point .25 is " + csv);
    }
}

Output

The computed cubic spline value at point .25 is -0.548772503812158

Link to C# source.