P3trus
P3trus

Reputation: 7225

Cubic spline representation from second derivative

I've got a dataset from a paper, where the datapoints x, y and the second derivative y" is given. The authors state that this is used to get a cubic spline representation.

My Question is:

How do I get the spline representation with scipy incorporating the second derivative?

Upvotes: 2

Views: 1578

Answers (1)

Paul Panzer
Paul Panzer

Reputation: 53029

The authors are almost certainly referring to using the second derivatives at the very endpoints of the data.

In cubic spline interpolation once you've specified the values you have 2 degrees of freedom left, indeed: n + 1 nodes gives you n polynomials with 4 n parameters of these you spend n + 1 to fit the values and 3 for consistency at each of the n - 1 joints, leaving 2.

You can use scipy.interpolate.CubicSpline; the appropriate boundary condition would be bc_type=((2, y"0), (2, y"n)) where y"0 and y"n are the second derivatives at the first and last data points.

Upvotes: 2

Related Questions