In an algorithm I am writing, I need to solve the equation

$$ \det{(A+\epsilon B)} = 0, $$

for the smallest value of $\epsilon$, given large ($n$x$n$ ideally up to 150x150), dense and symmetric A and B. In the algorithm, I invert $B$ and have Mathematica solve the equation $\det(B^{-1}A+\epsilon I)=0$ by Eigenvalues[$B^{-1}A$].

This works fine for $n<20$, then I start getting errors:

Result for Inverse of badly conditioned matrix [$B$] may contain significant numerical errors.

As the algorithm runs, $B$ becomes more singular and wrecks the calculations. One thing that would help my algorithm is a way to solve the original equation fast in Mathematica without inverting $B$, but I am struggling to come up with one!

Anyone know a way?

  • 1
    $\begingroup$ This really needs a concrete example. Are the matrices comprised of approximate reals? Rationals? Gorillas? $\endgroup$ Nov 14, 2018 at 14:53

1 Answer 1


You can use the generalized form of Eigenvalues. Example matrices:

{A, B} = RandomReal[1, {2, 4, 4}];


Eigenvalues[Inverse[B] . A]
Eigenvalues[{A, B}]

{2.41802, 1.42315, 0.685593, -0.296285}

{2.41802, 1.42315, 0.685593, -0.296285}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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