I am trying to compute the Jacobian matrix J. In my case, f and x are 3-vectors (my vectors are named g and a instead), so J should be a 3X3 matrix.
Here's the code I'm using:
a = {{a1}, {a2}, {a3}} // MatrixForm
g = {{Subscript[l, 1]*Cos[a1] + Subscript[l, 2]*Cos[a1 + a2] +
Subscript[l, 3]*Cos[a1 + a2 + a3]}, {Subscript[l, 1]*Sin[a1] +
Subscript[l, 2]*Sin[a1 + a2] + Subscript[l, 3]*Sin[a1 + a2 + a3]},
{a1 + a2 + a3} } // MatrixForm
J = D[g, a] // MatrixForm
This is the output I get in Mathematica:
Based on the suggestions from another discussion, I also tried
J = D[g, {a}]
and
J = JacobianMatrix[g, a]
but neither worked. Can someone tell me why I'm not getting the correct Jacobian matrix, and share code for the correct method?