express basis spline derivative in terms of interpolation values

207 views (last 30 days)
x = [1 2 3 4 5];
y = randn(size(x));
f = spapi(5,x,y);
fdd = fnder(f, 2);
If we evaluate the second derivative at a given point x* as
xeval = 3.5;
val = fnval(fdd, xeval)
is there a way to express "val" as a linear combination of the interpolation values as
val = y(1)*c1 + ... + y(5)*c5
Then, the task is to find the coefficients ci.
Can this be done with symbolic differentiation or other techniques? Or is there an easy analytical representation for that?
Thank you!

Accepted Answer

Bruno Luong
Bruno Luong on 28 Mar 2024 at 18:24
x = [1 2 3 4 5];
y = randn(size(x));
k = 5;
f = spapi(k,x,y);
B = spapi(k,x,eye(length(x)));
fdd = fnder(f, 2);
Bdd = fnder(B,2);
xeval = 3.5;
val = fnval(fdd, xeval)
val = 1.5349
c = fnval(Bdd, xeval);
vcomb = y * c
vcomb = 1.5349
err = val-vcomb
err = 8.8818e-16
  34 Comments
SA-W
SA-W on 4 Apr 2024 at 19:15

Honestly I dont understand what you want to achieve your code. Why do you put positive constraint on fdddd(x(end)) and not fddd(x(end))? I don't know what is your goal

Oh, you are right. To have s''(x)>0 for x>x(end), I thought the fourth derivative must be positive at x(end). But s'''(x(end)) is sufficient, right?

(I will not ask further after this and say thanks a lot for helping!! :-))

Bruno Luong
Bruno Luong on 4 Apr 2024 at 20:28
You might need to impose both conditions of third and fourth derivative on x(end).

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!