I consider myself to be an inexperienced Mathematica user so maybe someone could point out what am I doing wrong.

In short, here is what I want to get: suppose that there is a matrix of dimension $ N \times N $. I know that at least one of the eigenvalues should always be zero. What I need to determine is the maximum number of non-zero eigenvalues; no need for explicit ones. I found out that the function MatrixRank should do it. I came across one of the matrices, which seemed to "violate" the rule for eigenvalues, in the sense that I wasn't getting a zero eigenvalue. Later I was pointed out that determinant of the given matrix is "0".

Here comes the issue. 2 functions return different results for a matrix of dimension 3:

Simplify[Det[M]] ->  0 
MatrixRank[M]    ->  3

Due to the specific matrix being way too long, I include a link to it. This is the original matrix, I use TrigToExp afterwards as it seemed to reduce the computation process time. In both cases I got the same result for Det and MatrixRank.

P.S. I need a symbolic evaluation and am currently using Mathematica

  • 2
    $\begingroup$ If one of the eigenvalues are 0, then the determinant is zero, because the determinant equals the product of all eigenvalues... $\endgroup$ – Marius Ladegård Meyer Oct 25 '18 at 12:47
  • 1
    $\begingroup$ When Mathematica calculated the MatrixRank with symbolic entries, it gives the "most general"/"least specific" value of the rank. Maybe that is your issue... $\endgroup$ – Marius Ladegård Meyer Oct 25 '18 at 12:49
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Chris K Oct 25 '18 at 12:56
  • $\begingroup$ Thank you for comments. I am still interested if it would be possible to determine amount of the non-zero eigenvalues without using numerical evaluation. Or maybe there are some other mathematical possibilities of doing that? In principle, this could be further reduced by hand, but I want a more or less to automate it as there are way more matrices. $\endgroup$ – Anton K Oct 25 '18 at 12:57
  • $\begingroup$ Did you try NullSpace? Presumably this gives the dimension of the nullspace, which is the number of zero eigenvalues. $\endgroup$ – bill s Oct 31 '18 at 16:32

If a numerical method is acceptable, you can find the characteristic polynomial, and then find out how many coefficients are zero. Let mat be your matrix. Then:

coeff = CoefficientList[CharacteristicPolynomial[mat, x], x];

With[{v = Reduce`FreeVariables @ mat},
    rules = Thread[v -> RandomReal[10, Length @ v, WorkingPrecision->50]]
coeff /. rules

{0.*10^-45 + 0.*10^-45 I, -88.06869475049593825389409426950881792625734818 + 0.*10^-46 I, 41.6148105746435957281515196867572568226297329616, -1.000000000000000000000000000000000000000000000000}

This shows that the matrix rank is at least 2 (only the constant term is zero).

Or, just use Eigenvalues:

Eigenvalues[mat /. rules]
Chop @ %

{39.378334721261585770434684505881112377002680998 - 8.9642095056061798556155811000294566716875029005*10^-58 I, 2.23647585338200995771683518087614444562705196366 + 5.0089274479735025489970467486450317946657226813*10^-58 I, 2.48749661365029255751887504501496855632934665698*10^-60 - 6.4330798253441844711669847353350620993805252084*10^-60 I}

{39.378334721261585770434684505881112377002680998, 2.23647585338200995771683518087614444562705196366, 0}

I think the characteristic polynomial approach is probably a bit more robust, since it avoids root finding.

  • $\begingroup$ CharacteristicPolynomial with approximate numeric input uses Eigenvalues. $\endgroup$ – Daniel Lichtblau Oct 31 '18 at 17:25
  • $\begingroup$ @DanielLichtblau Did not know that. However, my use of CharacteristicPolynomial had exact input, so I don't think your comment is relevant? $\endgroup$ – Carl Woll Oct 31 '18 at 17:36
  • $\begingroup$ If mat is exact then CharacteristicPolynomial[mat] will use different methods e.g. polynomial interpolation for integer/rational matrices (and that will be much faster than Eigenvalues). $\endgroup$ – Daniel Lichtblau Oct 31 '18 at 19:59

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.