3
$\begingroup$

I want to build a matrix J for each of the solutions of an equation. And each solution is also a set of 3 variables (x,y,z).

In the end, I want to calculate the eigenvalues of J for J applied to each of the solutions in the solution set.

I know how to apply the matrix J for a given solution,

J/.{ x -> a, y -> b, z-> c }

if the solution was (x,y,z)=(a,b,c)

However, the solution is, for instance,

{{x -> a, y -> b, z -> c}, {x -> d, y -> e, z -> f}}

So I want to loop over the solution list and apply J for each specific solution. How can I do that in an automated way? The simpler, the better... I don't to have to really "code" in Mathematica.

Here is my real problem:

I start from the function

F[x_, y_, z_, a_, b_, c_, d_] := (1 - a + b - (b/3) (c x + d (y + z))) x

which generates this set of fixed points (each element of the list FP is a solution)

FP = Solve[{x == F[x, y, z, a, b, c, d], y == F[y, x, z, a, b, c, d], z == F[z, x, y, a, b, c, d]}, {x, y, z}]

Then I build the Jacobian matrix:

J = FullSimplify[
  {{D[F[x, y, z, a, b, c, d], x], D[F[x, y, z, a, b, c, d], y], D[F[x, y, z, a, b, c, d], z]},
   {D[F[y, x, z, a, b, c, d], x], D[F[y, x, z, a, b, c, d], y], D[F[y, x, z, a, b, c, d], z]},
   {D[F[z, x, y, a, b, c, d], x], D[F[z, x, y, a, b, c, d], y], D[F[z, x, y, a, b, c, d], z]}}
  ]

I can calculate the eigenvalues of J applied to the first solution like this:

Eigenvalues[J/.FP[[1,All]]]

But how do I do that iteratively, generating another list?

Thanks

$\endgroup$
  • 5
    $\begingroup$ Are you perhaps aware that you can generate the Jacobian in one blow: D[{F[x, y, z, a, b, c, d], F[y, x, z, a, b, c, d], F[z, x, y, a, b, c, d]}, {{x, y, z}}]? $\endgroup$ – J. M.'s discontentment Jul 8 at 14:22
  • $\begingroup$ No, I wasn't... thanks! I'm completely new to Mathematica... $\endgroup$ – Girardi Jul 8 at 14:24
3
$\begingroup$

The simplest way to do that is to use:

EV = FullSimplify[Table[Eigenvalues[J /. f], {f, FP}]]
| improve this answer | |
$\endgroup$
2
$\begingroup$

You do not need to iterate manually. First use ReplaceAll to substitute all eight solutions contained in FP, which will give you a list of 8 J expressions. Then Map the Eigenvalues function over the list: this will apply Eigenvalues to each element of the list of Js in turn, to give you the eight results, one for each solution from FP:

Eigenvalues /@ (J /. FP)

Here are the results:

{
 {1 + a - b, 
  -((-c + a c - b c - a d + b d)/c),
  -((-c + a c - b c - a d + b d)/c)},

 {1 + a - b, 
  (c - a c + b c + d + a d - b d)/(c + d), 
  (c + a c - b c + d - a d + b d)/(c + d)},

 {1 + a - b, 
  -((-c + a c - b c - a d + b d)/c),
  -((-c + a c - b c - a d + b d)/c)},
 
 {1 + a - b,
  (c + a c - b c + 2 d - a d + b d)/(c + 2 d), 
  (c + a c - b c + 2 d - a d + b d)/(c + 2 d)},

 {1 + a - b, 
  (c - a c + b c + d + a d - b d)/(c + d), 
  (c + a c - b c + d - a d + b d)/(c + d)}, 

 {1 + a - b,
  -((-c + a c - b c - a d + b d)/c),
  -((-c + a c - b c - a d + b d)/c)}, 

 {1 + a - b, 
  (c - a c + b c + d + a d - b d)/(c + d), 
  (c + a c - b c + d - a d + b d)/(c + d)},

 {1 - a + b, 
  1 - a + b, 
  1 - a + b}
}

While we are at it, you do not need the All in FP[[1, All]]; FP[[1]] already means "the first element of FP, whatever is in it". You would use All if you wanted a specific column instead: FP[[All, 2]], which you can read to say: "take the second element from within all elements of FP".

Also, as @J.M. mentioned in comments, your Jacobian can be more simply obtained from:

FullSimplify@
 D[
   {F[x, y, z, a, b, c, d], F[y, x, z, a, b, c, d], F[z, x, y, a, b, c, d]}, 
   {{x, y, z}}
 ]
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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