splineDiff(s, n)

Differentiates (from right) a spline.

sThe spline to be differentiated.
n(Optional, defaults to 1) The order of differentiation.
return valueThe derivative.

xy = [-100,4; 8,93; 42,-88; 444, 827]; xmin = min(xy[...;0]); xmax = max(xy[...;0]); eps = (xmax-xmin)/200; xmin -= 2*eps; xmax += 2*eps; x = xmin..eps..xmax; p = splineInterp(xy); print("The interpolating normal cubic spline.").title() plot(x, (@(x) splineEval(p,x))(#x)); print("Its derivative.").title() plot(x, (@(x) splineEval(splineDiff(p),x))(#x)) print("Its 2nd derivative.").title() plot(x, (@(x) splineEval(splineDiff(p,2),x))(#x)) print("Its 3rd derivative.").title() plot(x, (@(x) splineEval(splineDiff(p,3),x))(#x))