B-Spline Basis

Derivative Bug Patch

Yu-Sung Chang
Wolfram Research, Inc.

Fix

Geometricfunctions`ZeroD[x_,y_]:=If[y==0, 0, x / y];
Unprotect[BSplineBasis];	
Derivative[{0, {0..}}, 0, 1][BSplineBasis] ^= 
	(If[Length[{##}]===3 && (Length[#1]===2) && !ListQ[First[#1]],
		With[{d = First[#1], U = Last[#1], i = #2, x = #3},
			Geometricfunctions`ZeroD[d, U[[i+d+1]]-U[[i+1]]] * BSplineBasis[{Max[d-1, 0], U}, i, x] - Geometricfunctions`ZeroD[d, U[[i+d+2]]-U[[i+2]]] * BSplineBasis[{Max[d-1, 0], U}, i+1, x]
		]
	] &);
Protect[BSplineBasis];

Examples

knots={0,0,0,1/3,2/3,1,1,1};

Table[Plot[Evaluate[D[BSplineBasis[{2,knots},2,x],{x,i}]],{x,0,1}],{i,0,2}]

Grid[Table[Table[Plot[Evaluate[D[BSplineBasis[{2,knots},j,x],{x,i}]],{x,0,1},PlotRange->All],{i,0,3}],{j,0,4}]]