Thursday, April 29, 2010

Jacobian function for Mathematica

Following up on the vector valued functions, here's a way to compute Jacobian matrices for them:

In: jacobian[f_, c_] := Transpose[Map[D[f[c], #] &, c]]


You need to pass in a list of components for the vector argument along with the vector valued function:

In: f[{x_, y_}] := {2 x^2 y, x*y}


In: jacobian[f, {x, y}]


Out: {{4 x y, y}, {2 x^2, x}}


-a