1
$\begingroup$

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:

enter image description here

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?

$\endgroup$
  • $\begingroup$ Why not doing the multiplication inside one Table ? $\endgroup$ – b.gates.you.know.what Apr 30 '13 at 14:53
  • $\begingroup$ 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}] $\endgroup$ – MaTECmatica Apr 30 '13 at 14:58
  • $\begingroup$ @b.gatessucks: yes, both your answers solve my problem and give me the result I want! $\endgroup$ – seb Apr 30 '13 at 15:01
  • $\begingroup$ @QuantumMathematica: yes, both your answers solve my problem and give me the result I want! $\endgroup$ – seb Apr 30 '13 at 15:02
  • $\begingroup$ 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}] $\endgroup$ – J. M. is away Apr 30 '13 at 15:08
1
$\begingroup$
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}]

enter image description here

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}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.