# Clamped Cubic Spline

Hi all,

I am trying to use cubic spline interpolation where I specify the derivatives at the endpoint. The functions I am trying to interpolate with are value functions and thus often have poles at 0. As a consequence, I sometimes run into weird behavior with say normal splines. I had thought that I perhaps I could improve the quality of the interpolation by specifying that the derivatives of the spline interpolation at the endpoints of the grid be equal to the derivative of the utility function.

I have read the documentation of Interpolations, and it doesn’t seem to me that it supports clamped splines in this way, but happy to be told I am wrong!

Thanks!

I’m not currently aware of the ability to do this in Interpolations.jl. Note there are many other interpolation packages.

For example, BasicInterpolators.jl seems to do what you want:
https://markmbaum.github.io/BasicInterpolators.jl/dev/1d/#BasicInterpolators.CubicSplineInterpolator

2 Likes

If you know a priori that you have a pole at zero, I would try to remove this singularity analytically before doing a spline fit.

For example, if you have data (x_k, y_k) for f(x) which has a known simple pole at x=0, I would instead do a spline fit for x \times f(x), i.e. fit (x_k, x_k \times y_k) to a spline s(x), and your desired function is s(x) / x.

4 Likes

Thank you, this is certainly a different idea from what I had in mind but I will try it!