4
$\begingroup$

I want to plot Sum[E[i]] verseus t where E[i] are the negative eigenvalues of the matrix:

M1 = {{5 t, 0, 0, t^2}, {0, -30 + t, 0, 0}, {0, 0, -30 + t, 0}, {t^2, 
   0, 0, 1 + 2 t}}
$\endgroup$

1 Answer 1

9
$\begingroup$
Plot[Evaluate[Eigenvalues[M1]], {t, 0, 10}, PlotLegends -> "Expressions"]

enter image description here

sumofnegativeeigenvalues = Total @ - Ramp @ - Eigenvalues[M1]
-2 Ramp[30 - t] - 
 Ramp[1/2 (-1 - 7 t - Sqrt[1 - 6 t + 9 t^2 + 4 t^4])] - 
 Ramp[1/2 (-1 - 7 t + Sqrt[1 - 6 t + 9 t^2 + 4 t^4])]
Plot[sumofnegativeeigenvalues, {t, 0, 10}, AxesOrigin -> {0, 0}]

enter image description here

Alternatively,

ClearAll[sumNegEigenVals]
sumNegEigenVals = Eigenvalues /* Minus /* Ramp /* Minus /* Total;

sumNegEigenVals @ M1 == sumofnegativeeigenvalues
True
$\endgroup$
1
  • 2
    $\begingroup$ Not going to lie, I've just had to figure out what @ - means. $\endgroup$
    – SPPearce
    May 11, 2020 at 12:20

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.