Below is my toyproblem code I am trying to improve.
Remove["Global`*"];//Quiet
ClearAll;
matrix={{(2*x-5)^2+2,x+2},{x^5/(x-7)^2,1/x}};
matrix//MatrixForm
determinant=Det[matrix]
step1=Together[determinant]
step2=Factor[Distribute[x*(x-7)^2*step1]]
rootsWithDenominator=x/.NSolve[step1==0,x]//TableForm
rootsWithOutDenominator=x/.NSolve[step2==0,x]//TableForm
And the output is
(2+(-5+2 x)^2 2+x
x^5/(-7+x)^2 1/x)
-(1358/(-7+x)^2)+1323/((-7+x)^2 x)+(503 x)/(-7+x)^2-(76 x^2)/(-7+x)^2+(4 x^3)/(-7+x)^2-(2 x^5)/(-7+x)^2-x^6/(-7+x)^2
(1323-1358 x+503 x^2-76 x^3+4 x^4-2 x^6-x^7)/((-7+x)^2 x)
1323-1358 x+503 x^2-76 x^3+4 x^4-2 x^6-x^7
-3.74679+2.34084 I
-3.74679-2.34084 I
0.24533 +3.05429 I
0.24533 -3.05429 I
1.6188 +1.21207 I
1.6188 -1.21207 I
1.76533
-3.74679-2.34084 I
-3.74679+2.34084 I
0.24533 -3.05429 I
0.24533 +3.05429 I
1.6188 -1.21207 I
1.6188 +1.21207 I
1.76533
My goal is to find all x's when determinant of matrix is equal to zero. As you can see, I have step2 to eliminate denominator which does not contribute to number of roots to find. When you look at the output of NSolve
of step1 and step2 they look almost the same. However, for very complicated equation the difference is in speed (I've seen 10 fold increase in speed of finding roots.) Another difference is the order of roots that are placed in the column (note minus signs)
Is there another way to implement step2 to eliminate denominators without typing in denominators and without going through the symbolic 'Solve' process? I have tried something like Simplify[step1==0]. But denominators are still there.
Numerator
? $\endgroup$