1
$\begingroup$

I want to calculate the Jacobian of three functions. Following the mathematical way of calculating I do:

u[x_, y_, z_] := 9 x^2 y^2 + z E^x
v[x_, y_, z_] := x y + x^2 y^3 + 2*z
w[x_, y_, z_] := Cos[x]*Sin[z]*E^y
{
 {D[u[x, y, z], x], D[u[x, y, z], y], D[u[x, y, z], z]},
 {D[v[x, y, z], x], D[v[x, y, z], y], D[v[x, y, z], z]},
 {D[w[x, y, z], x], D[w[x, y, z], y], D[w[x, y, z], z]}
}

Where E is the Euler number expressed in Mathematica.

And I get the Jacobian.

I have seen that there is a function named JacobianMatrix which I understand shall give the same result.

I try this without success:

JacobianMatrix[{u[x, y, z], v[x, y, z], w[x, y, z]}, {x, y, z}]
  • Would that function be used to calculate the Jacobian?
  • If so, what is wrong in the way I am invoking it?
$\endgroup$
5
  • 4
    $\begingroup$ D[{u[x, y, z], v[x, y, z], w[x, y, z]}, {{x, y, z}, 1}] or Grad[{u[x, y, z], v[x, y, z], w[x, y, z]}, {x, y, z}] $\endgroup$
    – cvgmt
    Commented Aug 20, 2022 at 10:21
  • 3
    $\begingroup$ and Det@Grad is the Jacobian. $\endgroup$
    – cvgmt
    Commented Aug 20, 2022 at 10:28
  • $\begingroup$ If you mean this then the syntax is ResourceFunction["JacobianMatrix"][{u[x,y,z],v[x,y,z],w[x,y,z]},{x,y,z}]. Anyhow, I am with @cvgmt. I think it would be good if typing "Jacobian" into the documentation center search bar would direct one to D and Grad, as first and second search result, not to some ResourceFunction. $\endgroup$
    – user293787
    Commented Aug 20, 2022 at 11:14
  • 1
    $\begingroup$ @user293787 I guess since Jacobian is a system symbol and option to FindRoot, I'd expect FindRoot to be the top hit. For me, it's 4th and D is 5th. I don't get a resource function hit on the first page. Maybe it's a difference in how our systems are set up or versions or the online docs (I'm on V13.1/Mac). (My top 2 hits are optimization tutorials and the 3rd is CoordinateTransformData.) $\endgroup$
    – Michael E2
    Commented Aug 20, 2022 at 15:25
  • $\begingroup$ @MichaelE2 I was here reference.wolfram.com/search/?q=Jacobian where 1st and 2nd place are resource functions. Locally I do not get resource functions, but the rest is in the same order with D in 5th place (Version 12.3/Linux). $\endgroup$
    – user293787
    Commented Aug 20, 2022 at 15:32

2 Answers 2

2
$\begingroup$

I think the shortest way to achieve what you are looking for is as follows:


u[x_, y_, z_] := 9 x^2 y^2 + z E^x;

v[x_, y_, z_] := x y + x^2 y^3 + 2 z;

w[x_, y_, z_] := Cos[x] Sin[z] E^y;

jacobian = D[{u[x, y, z], v[x, y, z], w[x, y, z]}, {{x, y, z}}]

$\endgroup$
0
$\begingroup$

Try this

f[x1, x2, x3] = {9 x1^2 x2^2 + x3 E^x1, x1 x2 + x1^2 x2^3 + 2*x3, Cos[x1]*Sin[x3]*E^x2}

(J = Table[ Table[D[f[x1, x2, x3][[i]], xi], {xi, {x1, x2, x3}}], {i, 1, 3}]) // MatrixForm

I hope this will help you. All the best

$\endgroup$
3
  • 4
    $\begingroup$ Please post the code instead of pictures. $\endgroup$
    – cvgmt
    Commented Aug 20, 2022 at 11:41
  • $\begingroup$ f[x1, x2, x3] = {9 x1^2 x2^2 + x3 E^x1, x1 x2 + x1^2 x2^3 + 2*x3, Cos[x1]*Sin[x3]*E^x2} (J = Table[ Table[D[f[x1, x2, x3][[i]], xi], {xi, {x1, x2, x3}}], {i, 1, 3}]) // MatrixForm $\endgroup$ Commented Aug 20, 2022 at 11:45
  • $\begingroup$ Although this generates the desired Jacobian matrix, it does not answer the OP's question. $\endgroup$
    – bbgodfrey
    Commented Aug 20, 2022 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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