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.

Code:

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 == 1, y == 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!

• also tried Evaluate and @@
– root
Mar 19, 2020 at 0:46
• 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.
– root
Mar 19, 2020 at 0:54
• 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.
– root
Mar 19, 2020 at 1:02
• this is not working: JC[xx_, yy_] := JacobianMatrix[{f[x, y], g[x, y]}, {x, y}] /. {x -> xx, y -> yy} Map[JC, {{lx,ly}}]
– root
Mar 19, 2020 at 1:05
• Why didn't you fix the error by editing the question? Mar 19, 2020 at 1:12

Method 1:

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


Method 2:

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


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}}]

• 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.
– root
Mar 19, 2020 at 1:21
• Thanks! It works perfectly. I've tried for hours with no luck... Mathematica learning curve is a bit steep...
– root
Mar 19, 2020 at 4:19
• @CharlesM You're welcome. :) Mar 19, 2020 at 12:48
• 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
– root
Mar 19, 2020 at 18:29