Group Abstract Group Abstract

Message Boards Message Boards

Plotting a function which has eingenvalues of a matrix?

Posted 3 years ago

I have constructed the elements of the following 4x4 matrix solving some differential equation, namely "sol":

 \[Rho][t] := {{Subscript[\[Rho], gg][t] /. sol, 0, 0, 
   Subscript[\[Rho], ge][t] /. sol}, {0, 
   Subscript[\[Rho], ss][t] /. sol, Subscript[\[Rho], sa][t] /. sol, 
   0}, {0, Subscript[\[Rho], as][t] /. sol, 
   Subscript[\[Rho], aa][t] /. sol, 
   0}, {Subscript[\[Rho], eg][t] /. sol, 0, 0, 
   Subscript[\[Rho], ee][t] /. sol} }

I would like to use the eingenvalues $\lambda_{i}[t]$ of this matrix in the following function:

Max[0, Sqrt[\[Lambda] /. einge[1]] - Sqrt[\[Lambda] /. einge[2]] - 
    Sqrt[\[Lambda] /. einge[3]] - Sqrt[\[Lambda] /. einge[4]]] 

I've tried, with no success, the following:

einge := Eigenvalues[\[Rho][t]]
Plot[Evaluate[{Max[0, 
        Sqrt[ einge[1]] - Sqrt[ einge[2]] - Sqrt[ einge[3]] - 
         Sqrt[einge[4]]]} /. einge], {t, 0, 100}]

Can someone help me to found the right way to plot this function?

POSTED BY: Matheus Soares

Hello Matheus

1) I suggest NOT to use variables with subscripts, that may lead to problems

2) What is sol? Without sol your matrix rho is not defined

3) Here ( I arbritarily define a matrix rho ) is some code which seems to do what you want.

I introduced Abs in the eigenvalues because it turned out that complex values occured.

I hope this gives you hints how to proceed

rho[t_] := {
  {1 + 1/t, 0, 0, t},
  {0, t^2, 2 + t, 0},
  {0, 2 + t, t^2, 0},
  {3 t, 0, 0, 2 t}}

rho[x] // MatrixForm

ev[t_] := Eigenvalues[rho[t]]
ee[j_, t_] := Abs[ev[t][[j]]]

Plot[Sqrt[ee[1, t]] - Sqrt[ee[2, t]] - Sqrt[ee[3, t]] -  Sqrt[ee[4, t]], {t, 1, 100}]

Plot[Max[-20, Sqrt[ee[1, t]] - Sqrt[ee[2, t]] - Sqrt[ee[3, t]] - Sqrt[ee[4, t]]], {t, 1, 100}]

And in abbreviated form:

Plot[Max[-20, Re@({1, -1, -1, -1}.Sqrt[Abs[ev[t]]])], {t, 1, 100}]
POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard