Example: The Kochanek-Bartels cubic spline interpolant

This example interpolates to a set of points. At x = 3, the continuity and tension parameters are -1. At all other points, they are zero. Interpolated values are then printed.
using System;
using Imsl.Math;

public class CsTCBEx1
{
    public static void  Main(String[] args)
    {
        double[] xdata = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
        double[] ydata = {5.0, 2.0, 3.0, 5.0, 1.0, 2.0};
        double[] continuity = {0.0, 0.0, 0.0, - 1.0, 0.0, 0.0};
        double[] tension = {0.0, 0.0, 0.0, - 1.0, 0.0, 0.0};
        
        CsTCB cs = new CsTCB(xdata, ydata);
        cs.SetContinuity(continuity);
        cs.SetTension(tension);
        cs.Compute();
        Console.Out.WriteLine("    x    " + "  value   ");
        
        for (int k = 0; k < 11; k++)
        {
            double x = (double) k / 2.0;
            double y = cs.Eval(x);
            Console.Out.WriteLine(" {0,5:0.0000}    {1,5:0.0000}",x, y);
        }
    }
}

Output

    x      value   
 0.0000    5.0000
 0.5000    3.4375
 1.0000    2.0000
 1.5000    2.1875
 2.0000    3.0000
 2.5000    3.6875
 3.0000    5.0000
 3.5000    2.1875
 4.0000    1.0000
 4.5000    1.2500
 5.0000    2.0000

Link to C# source.