Example: The shape preserving cubic spline interpolant
A cubic spline interpolant to a function is computed consistent with the concavity of the data. The spline value at 0.05 is printed.
using System;
using Imsl.Math;
public class CsShapeEx1
{
public static void Main(String[] args)
{
double[] x = new double[]{0.00, 0.10, 0.20, 0.30, 0.40,
0.50, 0.60, 0.80, 1.00};
double[] y = new double[]{0.00, 0.90, 0.95, 0.90, 0.10,
0.05, 0.05, 0.20, 1.00};
CsShape cs = new CsShape(x, y);
double csv = cs.Eval(0.05);
Console.Out.WriteLine("The computed cubic spline value at " +
"point .05 is " + csv);
}
}
Output
The computed cubic spline value at point .05 is 0.55823122286482
Link to C# source.