# Plotting derivatives of B-splines

I am trying to solve an electrodynamics problem numerically by using B-splines a basis function. Please don't ask me why, but if you really wanna know, here is the assignment.

Using the following code, I have successfully plotted the B-spline basis functions in two dimensions, given the specific knot sequence and the respective x and y intervals.

knots = {0, 0, 0, 0, 0.2, 1, 1, 1, 1}
Plot3D[Evaluate[Table[BSplineBasis[{4, knots}, i, x], {i, 0, 3}]] Evaluate[
Table[BSplineBasis[{4, knots}, i, y], {i, 0, 3}]], {x, 0, 1}, {y, 0, 1}]


The corresponding plot looks like this: Now I am trying to do the same for the second derivatives of the B-splines, using the following code:

knots = {0, 0, 0, 0, 0.2, 1, 1, 1, 1}
Plot3D[Evaluate[Table[D[BSplineBasis[{4, knots}, i, x], {x, 2}], {i, 0, 3}]]
Evaluate[Table[D[BSplineBasis[{4, knots}, i, y], {y, 2}], {i, 0, 3}]],
{x, 0, 1}, {y, 0, 1}]


However, it does not work and produces an empty graph and lots of red error messages. I have tried several combinations of the D, Table and Evaluate operators, but nothing seems to work. What am I doing wrong?

• Why not doing the multiplication inside one Table ? Apr 30, 2013 at 14:53
• Is this what you want? knots = {0, 0, 0, 0, 0.2, 1, 1, 1, 1}; e1 = Evaluate[ Table[D[BSplineBasis[{4, knots}, i, x], {x, 2}], {i, 0, 3}]]; e2 = Evaluate[ Table[D[BSplineBasis[{4, knots}, i, y], {y, 2}], {i, 0, 3}]]; Plot3D[ e1*e2, {x, 0, 1}, {y, 0, 1}] Apr 30, 2013 at 14:58
• @b.gatessucks: yes, both your answers solve my problem and give me the result I want!
– seb
Apr 30, 2013 at 15:01
• @QuantumMathematica: yes, both your answers solve my problem and give me the result I want!
– seb
Apr 30, 2013 at 15:02
• Plot3D[Evaluate[Table[D[BSplineBasis[{4, knots}, i, \[FormalX]], {\[FormalX], 2}] D[BSplineBasis[{4, knots}, i, \[FormalY]], {\[FormalY], 2}] /. {\[FormalX] -> x, \[FormalY] -> y}, {i, 0, 3}]], {x, 0, 1}, {y, 0, 1}] Apr 30, 2013 at 15:08

knots = {0, 0, 0, 0, 0.2, 1, 1, 1, 1}; e1 =
Evaluate[Table[
D[BSplineBasis[{4, knots}, i, x], {x, 2}], {i, 0, 3}]]; e2 =
Evaluate[Table[
D[BSplineBasis[{4, knots}, i, y], {y, 2}], {i, 0, 3}]]; Plot3D[
e1*e2, {x, 0, 1}, {y, 0, 1}] Plot3D[Evaluate[
Table[D[BSplineBasis[{4, knots}, i, \[FormalX]], {\[FormalX], 2}] D[
BSplineBasis[{4, knots}, i, \[FormalY]], {\[FormalY],
2}] /. {\[FormalX] -> x, \[FormalY] -> y}, {i, 0, 3}]], {x, 0,
1}, {y, 0, 1}] 