2
$\begingroup$

Say you have a vector like the following

NN[\[Xi]_, \[Eta]_] := ( {
   {1/4 (1 - \[Xi]) (1 - \[Eta])},
   {1/4 (1 + \[Xi]) (1 - \[Eta])},
   {1/4 (1 + \[Xi]) (1 + \[Eta])},
   {1/4 (1 - \[Xi]) (1 + \[Eta])}
  } )

and you would like to construct a matrix of 2 columns, where the first column is the result of applying the derivative to the vector with respect to \[Xi] and the second column with respect to \[Eta]. I tried this:

DNN[\[Xi]_, \[Eta]_] := ( {
   {\!\(
     \*SubscriptBox[\(\[PartialD]\), \(\[Xi]\)]\(NN[\[Xi], \
\[Eta]]\)\), \!\(
     \*SubscriptBox[\(\[PartialD]\), \(\[Xi]\)]\(NN[\[Xi], \[Eta]]\)\)}
  } )

But then I get extra brackets (see figure).

enter image description here

Is there an easier way to do this than the brute force approach where I construct the matrix as follows?

DNN[\[Xi]_, \[Eta]_] := ( {
   {\!\(
     \*SubscriptBox[\(\[PartialD]\), \(\[Xi]\)]\(\(NN[\[Xi], \
\[Eta]]\)[\([1]\)]\)\), \!\(
     \*SubscriptBox[\(\[PartialD]\), \(\[Eta]\)]\(\(NN[\[Xi], \[Eta]]\
\)[\([1]\)]\)\)},
   {\!\(
     \*SubscriptBox[\(\[PartialD]\), \(\[Xi]\)]\(\(NN[\[Xi], \
\[Eta]]\)[\([2]\)]\)\), \!\(
     \*SubscriptBox[\(\[PartialD]\), \(\[Eta]\)]\(\(NN[\[Xi], \[Eta]]\
\)[\([2]\)]\)\)},
   {\!\(
     \*SubscriptBox[\(\[PartialD]\), \(\[Xi]\)]\(\(NN[\[Xi], \
\[Eta]]\)[\([3]\)]\)\), \!\(
     \*SubscriptBox[\(\[PartialD]\), \(\[Eta]\)]\(\(NN[\[Xi], \[Eta]]\
\)[\([3]\)]\)\)},
   {\!\(
     \*SubscriptBox[\(\[PartialD]\), \(\[Xi]\)]\(\(NN[\[Xi], \
\[Eta]]\)[\([4]\)]\)\), \!\(
     \*SubscriptBox[\(\[PartialD]\), \(\[Eta]\)]\(\(NN[\[Xi], \[Eta]]\
\)[\([4]\)]\)\)}
  } )
$\endgroup$
  • $\begingroup$ Is this what you want DNN[\[Xi]_, \[Eta]_] := Transpose[{\!\( \*SubscriptBox[\(\[PartialD]\), \(\[Xi]\)]\(NN[\[Xi], \[Eta]]\)\), \!\( \*SubscriptBox[\(\[PartialD]\), \(\[Eta]\)]\(NN[\[Xi], \[Eta]]\)\)}] $\endgroup$ – Hubble07 Sep 28 '15 at 17:42
2
$\begingroup$
DNN[ξ_, η_] := D[Flatten@NN[ξ, η], {{ξ, η}}]
DNN[ξ, η] // MatrixForm

enter image description here

(The first column is w.r.t ξ and the second is w.r.t to η. In the question both are computed w.r.t to ξ, although the wording indicates that both partial derivatives are desired.)

| improve this answer | |
$\endgroup$
0
$\begingroup$

You can use Flatten to remove the extra parentheses:

Transpose[Flatten[DNN[ξ, η], 1]];
MatrixForm[%]

enter image description here

| improve this answer | |
$\endgroup$
0
$\begingroup$
Transpose[Inner[D[#1, #2] &, Transpose[NN], {\[Xi]_, \[Eta]_}, List]]
| improve this answer | |
$\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.