by calebh · 8y ago · 0 comments
Mathematica doesn't seem to be able to do matrix calculus, which surprised me quite a bit.
f[x_,y_] := x^2 + Sin[y]
vars={x,y};
Table[ D[f[x,y],var1, var2], {var1,vars}, {var2,vars}] // MatrixForm
A = {{1,2},{3,4}}
vec = {x^2, x^3}
D[vec.A.vec, x]
Or perhaps like this, again the table of derivatives:
xvec = {x1,x2}
Table[ D[xvec.A.xvec,x] ,{x,xvec}]
(all untested... one typo caught...)