Motivation
I am numerically evaluating a deeply-nested multiple integral. At each nesting level I get a vector of integrals at the level below, which are multiplied by a vector of density functions to give the vector of integrands y
at this level. The x
values are unevenly spaced.
The integrand is curved and a trapezoidal integration is not sufficiently accurate, so I want to do an integration that allows for curvature. Simpson's Rule is not applicable because the abscissae are not evenly spaced. So I propose to do a cubic spline interpolation and then calculate the integral of the spline function by analytically calculating the integral of the cubic in each segment.
Question
I have been looking at functions like spline
and splinefun
as well as those in the splines2
package. But I cannot find anything that tells me the coefficients of the series of cubic polynomials - one per segment between knots.
I would be grateful if somebody could point me to a function that does the spline interpolation and makes available the array of cubic coefficients.
Thank you.