I am new to Mathematica. I just want to evaluate a 2x2 Jacobian and then evaluate it on different values of the two variables x and y.

The values I want to use to evaluate the Jacobian are the result of NDSolve.


f[x_, y_] := 2 - 10 x^2;
g[x_, y_] := 10 y - 2 y^2;

sol = NDSolve[{x'[t] == f[x[t], y[t]], y'[t] == g[x[t], y[t]], x[0] == 1, y[0] == 1}, {x, y}, {t, 0, 10}];

JacobianMatrix[f_List?VectorQ, x_List] := 
  Outer[D, f, x] /; Equal @@ (Dimensions /@ {f, x});

lx = Flatten[Map[x, Range[0, 10, 0.1]] /. sol];
ly = Flatten[Map[y, Range[0, 10, 0.1]] /. sol];

Now I want to evaluate the

JacobianMatrix[{f[x, y], g[x, y]}, {x, y}]

on the values of lx and ly (no combinations), just take one value of each one and produce a Jacobian.

I've tried Map and Table and combinations with no result.

Any help is welcomed. Thanks!

  • $\begingroup$ also tried Evaluate and @@ $\endgroup$
    – root
    Mar 19, 2020 at 0:46
  • $\begingroup$ I am trying with few values to try to make it work, for example JacobianMatrix[{f[x, y], g[x, y]}, {x, y}] /@ {{0, 1}} with no luck. $\endgroup$
    – root
    Mar 19, 2020 at 0:54
  • $\begingroup$ this is working but not giving the intended result: JC[{xx_, yy_}] := JacobianMatrix[{f[x, y], g[x, y]}, {x, y}] /. {x -> xx, y -> yy} JC /@ {{lx, ly}} Because I need a list of Jacobian matrices as result. $\endgroup$
    – root
    Mar 19, 2020 at 1:02
  • $\begingroup$ this is not working: JC[xx_, yy_] := JacobianMatrix[{f[x, y], g[x, y]}, {x, y}] /. {x -> xx, y -> yy} Map[JC, {{lx,ly}}] $\endgroup$
    – root
    Mar 19, 2020 at 1:05
  • 2
    $\begingroup$ Why didn't you fix the error by editing the question? $\endgroup$
    – Michael E2
    Mar 19, 2020 at 1:12

1 Answer 1


Method 1:

ans = Transpose[
    D[{f[x, y], g[x, y]}, {{x, y}}] /. {x -> lx, y -> ly},
   {2, 1, 3}];
MatrixForm /@ ans

Method 2:

ans = MapThread[
   Function[{x, y}, Evaluate@D[{f[x, y], g[x, y]}, {{x, y}}]],
   {lx, ly}];

Answer to original question

Your Jacobian matrix is constant. There's no need to evaluate it at many different points.

JacobianMatrix[{f[x, y], g[x, y]}, {x, y}]
(*  {{-10, 0}, {0, 8}}  *)

Note a common way to compute the Jacobian matrix is (search for Jacobian the docs for D):

D[{f[x, y], g[x, y]}, {{x, y}}]
  • $\begingroup$ sorry, I've simplified the original problem to keep it simple and it was too much of a simplification... now I've set y^2 and x^2 the Jacobian is not constant. thanks. $\endgroup$
    – root
    Mar 19, 2020 at 1:21
  • $\begingroup$ Thanks! It works perfectly. I've tried for hours with no luck... Mathematica learning curve is a bit steep... $\endgroup$
    – root
    Mar 19, 2020 at 4:19
  • $\begingroup$ @CharlesM You're welcome. :) $\endgroup$
    – Michael E2
    Mar 19, 2020 at 12:48
  • $\begingroup$ I think what I've found difficult was to distinguish between the different types of objects that mathematica can handle. List, List of lists, Matrix, etc $\endgroup$
    – root
    Mar 19, 2020 at 18:29

Your Answer

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

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