First, here is sample code for a simple cubic spline. This assumes the values in X[] are monotonically increasing.

```
using MathNet.Numerics.Interpolation; // required header
double[] x = new double[13];
double[] y = new double[13];
for (int i = 0; i <= 12; i++)
{
x[i] = i * Math.PI / 12;
y[i] = Math.Sin(x[i]);
}
// create spline
CubicSpline CSpline = CubicSpline.InterpolateNatural(x, y);
// try test value
double test_x = 1.5 * Math.PI / 12; // this value not in x[]
double test_y = CSpline.Interpolate(test_x); // returns 0.3826
Console.WriteLine(test_x.ToString() + " " + test_y.ToString());
```

Now the hard part. Your question says you want to find the X that corresponds to a given Y. If the Y values are monotonic (increasing or decreasing), you can just swap the arrays and create a spline for X = f{(Y). If the Y values are not monotonic, as in the example, the InterpolateNatural method will not work. I tried it, and it returned an NaN. One of the other methods might work; I don’t know.

If the Y values are not monotonic, there is an underlying math issue. There will be more than one X value that corresponding to a given Y and no algorithm can reliably determine which one you want. In the example, 0.25*PI and 0.75*PI would return the same value of Y.

Edit: I belatedly saw the graph you posted on Stack Overflow with this question. It illustrates my last point. If you were to ask for a point where sales = $6000, it could return a date in either February or March. I don’t know your objective here, but in most cases a regression line would be more appropriate than a spline for this data.