Good Approximation for First Derivative at Endpoints for Cubic Spline Interpolation

differential equationsna.numerical-analysissplines

I'm using a cubic spline interpolation for given data points. The boundary condition for the spline is that $f'(a)$ and $f'(b)$ are given (I'm using a finite difference formula $\frac{y_1-y_0}{x_1-x_0}$ to calculate the first derivatives $f'(a)$ and $f'(b)$, so they are not really given). With $a$ and $b$ being the boundaries. I ran into the problem, that my second derivative becomes really inaccurate at the boundary, if $f'(a)$ and $f'(b)$ aren't good approximations. I can't use a natural spline, since I also need a value for the second derivative at the endpoints. I'm using the spline to solve a stiff PDE. Are there any other good methods to approximate the first derivative at the endpoints?

Best Answer

For instance, you can approximate $f(x)$ by the Newton interpolating polynomial $P(x)$ based on a number of nodes closest to (and including) a given endpoint $x_0$, and then approximate $f'(x_0)$ by $P'(x_0)$.


Here is an image of a Mathematica notebook illustrating this approach on simulated data:

enter image description here

Related Question