Suppose I have:

mM = {{D[#, x]&, D[#, y]&}, {D[#, y]&, D[#, z]&}} 
v = {f[x, y, z], g[x, y, z]}

I want to get $u=mMv=\{\frac{\partial f}{\partial x}+\frac{\partial g}{\partial y},\frac{\partial f}{\partial y}+\frac{\partial g}{\partial z}\}$.

I know I can do it element by element, but how to do it nicely, using matrix operation or something.

  • 1
    $\begingroup$ Have you seen Inner[]? $\endgroup$ – J. M.'s discontentment Jul 9 '16 at 3:15
  • $\begingroup$ @J.M. It still not obvious to me how to apply Inner[] in this case $\endgroup$ – an offer can't refuse Jul 9 '16 at 3:35

Your operation does not work because in this case it is not a matricial multiplication but a composition. Try

 mM = {{D[#, x] &, D[#, y] &}, {D[#, y] &, D[#, z] &}}
 v = {f[x, y, z], g[x, y, z]}
 apply[a_, b_] := Inner[#1[#2] &, a, b]

This answer come from the article http://www.mathematica-journal.com/issue/v8i4/tricks/contents/Tricks8-4_3.html. In this article, the autor uses a_.b_ for apply[a_, b_] but the answer is "Tag Times in a_.\ b_ is Protected. "

The operator must be applied any times for example --- two times

v1 = {x^2 y^2 z^2, x^2 y^2 Log[z]}
v2 = apply[mM, v1]
v3 = apply[mM, v2]
| improve this answer | |
  • 1
    $\begingroup$ Thanks for your answer, what if I want to apply mM twice on vector v? i.e. How to define a new function that acts as apply[mOp, apply[mOp, v]] $\endgroup$ – an offer can't refuse Jul 9 '16 at 7:55
  • $\begingroup$ I have edited the answer to give an example of applying the operator two times without more programming $\endgroup$ – cyrille.piatecki Jul 9 '16 at 8:29

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