Is there a way to have a cubic interpolation with boundary conditions for the 2nd and 1st derivative?
I am using Interpolations.jl
Here is an example
using Interpolations, Plots
x = 1:10
y = rand(10)
y = 0
y = 0
yitp = CubicSplineInterpolation(x, y, extrapolation_bc = Line())
xfine = 1:0.01:10
My goal is to have zero second and first derivatives in both boundary conditions.
Your condition is already satisfied:
julia> f(x) = yitp(x);
julia> grad(x) = Interpolations.gradient(yitp, x);
julia> lap(x) = Interpolations.hessian(yitp, x);
julia> plot(xfine, [f, grad, lap], label=["f(x)" "f'(x)" "f''(x)"])
Of course you are right!
I forgot to mention that I want the first derivative to be zero as well. I edited the question. Thanks!
You can do this if you solve for the coefficients of the B-splines explicitly using their values and derivatives at the gridpoints (as applicable in your problem), but AFAIK Interpolations.jl does not expose B-spline basis functions in its API.
See the different
src/b-splines/cubic.jl. You could add a new system.