1
$\begingroup$

One short question. If we have two matrices in fractional form, how to obtain the Eigenvalues[{A,B}] with maximum precision or get it also in fraction form?

$\endgroup$

2 Answers 2

5
$\begingroup$

The problem is that Eigenvalues[] does not support matrices with exact entries for the case of the generalized eigenproblem $\mathbf A\mathbf x=\lambda\mathbf B\mathbf x$. If you want to get exact solutions, and $\mathbf B$ is invertible, just execute RootReduce[Eigenvalues[Inverse[B].A]]; here, one does not have to worry about ill-conditioning as in the inexact case. If $\mathbf B$ is not invertible, but $\mathbf A$ is, then you need RootReduce[1/Eigenvalues[Inverse[A].B]] (the proof that this works is left as an exercise); if both $\mathbf A$ and $\mathbf B$ are singular, things are more complicated, and I'll just tell you to search for "singular pencils" in your favorite search engine.

$\endgroup$
12
  • $\begingroup$ You beat me to it! +1 $\endgroup$
    – Simon
    Dec 3, 2011 at 1:32
  • $\begingroup$ The situation was once similar to that of SingularValues[]/SingularValueList[]; the solution to that case was Eigenvalues[Transpose[A].A]. But of course, this is no longer needed in new Mathematica versions. $\endgroup$ Dec 3, 2011 at 1:38
  • 2
    $\begingroup$ Ah, what the heck: lucky for George, Wolfram had the foresight to have CharacteristicPolynomial[] support pencils; for the singular pencil case, compute the characteristic polynomial, use Solve[], and pad the results with Infinity or Indeterminate as needed, depending on the results of MatrixRank[] on the two given matrices. $\endgroup$ Dec 3, 2011 at 2:43
  • 1
    $\begingroup$ @George: Just use N[Root[...], prec] to get the precision (prec) that you need. In general there will be no "nice" way of writing the roots of a 31st degree polynomial. $\endgroup$
    – Simon
    Dec 3, 2011 at 12:50
  • 1
    $\begingroup$ Now you're being confusing @George. First you want them exact, and now you want them approximate... $\endgroup$ Dec 3, 2011 at 12:50
2
$\begingroup$

The Mathematica command Eigenvalues[{M,A}] finds the generalized eigenvalues $\lambda$ that satisfy the equation $ M v = \lambda A v$, for eigenvectors $v$. Unfortunately, this version of Eigenvalues does not support calculations with exact numbers or symbolic variables.

One way to proceed is to rearrange the generalized eigenvalue equation to $ A^{-1} M v = \lambda v$, then you can just use Eigenvalues[Inverse[A].M], provided $A$ is invertible.

Another way to get exact results is to solve it numerically with high precision then use an integer relation algorithm such as RootApproximant to identify the polynomial.

eVals = Eigenvalues[N[{M, A}, 100]];
RootApproximant[eVals, Method -> {"DegreeCost" -> 3}]

but this probably isn't a very sensible way to approach the problem!

$\endgroup$
12
  • $\begingroup$ but there is a problem with Eigenvalues[N[A,B],100]]; Mathematica doesn't accept. Here are the matrices completely reduced on fraction form 2shared.com/file/ce8hiO6b/Matrices_A_and_B.html but what is the exact solution Eigenvalues[A,B]? And when I got the solution in form $$ \text{Root}\left[162904315798572+67352586131695 \text{$\#$1}-20676989596643 \text{$\#$1}^2\right.$$ $$\left.-3696503332225 \text{$\#$1}^3+1238108808324 \text{$\#$1}^4-11958953768 \text{$\#$1}^5+53788 \text{$\#$1}^6\&,4\right] $$ how it looks like in numerical form? $\endgroup$
    – George
    Dec 3, 2011 at 12:18
  • $\begingroup$ I just looked at your matrices. The exact Eigenvalues[Inverse[A].M] works (took a couple of minutes on my machine) and yields Root objects of degree 31 with massive integer coefficients (~1000 digits). RootApproximant won't find these unless you use insane precision. A Root expression represents the abstract root of a polynomial. The order that they are defined in is defined in the documentation. They can be evaluated to arbitrary (within reason) precision using N[]. $\endgroup$
    – Simon
    Dec 3, 2011 at 12:37
  • 1
    $\begingroup$ Or use Eigenvalues[N[{M, A}, prec]] from the very beginning - and forget about exact expressions. $\endgroup$
    – Simon
    Dec 3, 2011 at 12:52
  • 2
    $\begingroup$ @J.M.: He hasn't got a good record on asking clear questions. (I probably should stop bothering trying to answer them...) $\endgroup$
    – Simon
    Dec 3, 2011 at 12:58
  • 1
    $\begingroup$ @George: Yeah, I don't think that in this case the error is anything to worry about. You can compare Eigenvalues[N[{A, B}, 50]] with N[Eigenvalues[Inverse[B].A], 50] to check. Apart from possible differences in ordering, they should be the same up to a small numerical error. $\endgroup$
    – Simon
    Dec 3, 2011 at 14:11

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.