How to set boundaries for interpolation / extrapolation?

I have the following code:

LinearSpline spline = LinearSpline.InterpolateSorted(new double[] { 0, 1, 2, 4 }, new double[] { 
-0.5, -0.5, -0.3, -0.2 });

spline.Interpolate(10);

I want to get “-0.2” as result instead of “0,099”. How can I set the right and lefts boundaries?

Did you try adding an additional term of -0.2?

Thanks Peter, at the moment I’m solving it using additional values on the extremes and .double.NegativeInfinity or double.PositiveInfinity.

LinearSpline spline = LinearSpline.InterpolateSorted(new double[] { double.NegativeInfinity, 0, 1, 2, 4, double.PositiveInfinity }, new double[] { -0.5, -0.5, -0.5, -0.3, -0.2, -0.2 });