# Solving $\det{(A+\epsilon B)}=0$ for large, symmetric and dense $A$ and $B$

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?

• This really needs a concrete example. Are the matrices comprised of approximate reals? Rationals? Gorillas? – Daniel Lichtblau Nov 14 '18 at 14:53

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

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


Compare:

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


{2.41802, 1.42315, 0.685593, -0.296285}

{2.41802, 1.42315, 0.685593, -0.296285}