4
$\begingroup$

I have a 2x2 complex matrix

> M = {
  {
    (16 k^2 w + gc^2 (I gm + 2 (w + wm)) + 
      4 (u - w) (u + w) (I gm + 2 (w + wm)) + 
      4 gc (2 I k^2 + w (gm - 2 I (w + wm)))) / 
      (8 k^2 + 2 (gc - 2 I (u + w)) (gm - 2 I (w + wm))),
    
    (-8 k^3 + k (I gc + 2 (u + w)) (I gm + 2 (w + wm))) / 
      (4 k^2 + (gc - 2 I (u + w)) (gm - 2 I (w + wm)))
  },
  {
    (-8 k^3 + k (I gc + 2 (u + w)) (I gm + 2 (w + wm))) / 
      (4 k^2 + (gc - 2 I (u + w)) (gm - 2 I (w + wm))),
    
    ((gm - 2 I w) (8 I k^2 + (gm - 2 I w) (I gc + 2 (u + w))) + 
      4 (I gc + 2 (u + w)) wm^2) / 
      (8 k^2 + 2 (gc - 2 I (u + w)) (gm - 2 I (w + wm)))
  }
}

I want to determine the real values of w for which this matrix is singular. I tried Solve[Det[M]=0] but it runs indefinitely on my machine.

$\textbf{Question}:$ Is there a more efficient way in Mathematica to solve for the real root of $Det[M]=0$ for $w$?

Any guidance would be appreciated.

$\endgroup$
1
  • 1
    $\begingroup$ Start by simplifying the determinant: det = Det[M] // FullSimplify; This reduces the LeafCount from 6839 to 141 $\endgroup$ Commented 2 days ago

3 Answers 3

3
$\begingroup$

For me, using V 14.3 on windows 10, simplifying the det or not, makes very little difference:

M = {{(16 k^2 w + gc^2 (I gm + 2 (w + wm)) + 
       4 (u - w) (u + w) (I gm + 2 (w + wm)) + 
       4 gc (2 I k^2 + w (gm - 2 I (w + wm))))/(8 k^2 + 
       2 (gc - 2 I (u + w)) (gm - 2 I (w + wm))), (-8 k^3 + 
       k (I gc + 2 (u + w)) (I gm + 2 (w + wm)))/(4 k^2 + (gc - 
          2 I (u + w)) (gm - 2 I (w + wm)))}, {(-8 k^3 + 
       k (I gc + 2 (u + w)) (I gm + 2 (w + wm)))/(4 k^2 + (gc - 
          2 I (u + w)) (gm - 2 I (w + wm))), ((gm - 
          2 I w) (8 I k^2 + (gm - 2 I w) (I gc + 2 (u + w))) + 
       4 (I gc + 2 (u + w)) wm^2)/(8 k^2 + 
       2 (gc - 2 I (u + w)) (gm - 2 I (w + wm)))}};
   m = Det[M];
   LeafCount[m]
   (*6839*)

   RepeatedTiming[Solve[m == 0, w]]

enter image description here

Compare, from clean kernel (not showing input again)

m=FullSimplify[m];
LeafCount[m]
(*141*)
RepeatedTiming[Solve[m == 0, w]]

enter image description here

You see, the timing difference is minimal. May be on your version Det is slow? Or was it Solve which is slow? It is not clear from your description since you said I tried Solve[Det[M]=0] so it could have been either Solve or Det which is slow on your version of Mathematica.

If it is Det, you can try this. Find Det using the CharacteristicPolynomial instead. Like this

 p = CharacteristicPolynomial[M, x]
 coeff = Coefficient[p, x, 0]
 detM = (-1)^2*coeff // Simplify
 Solve[detM == 0, w]

enter image description here

Now, I noticed delay on V 14.3, which happens when trying to Simplify the output of Solve above. But you did not do this, right? Unless you are not showing all the code you used.

i.e. this hangs, at least I waited for minutes and gave up.

 Simplify[Solve[detM == 0, w]]

Removing Simplify from the above command, Solve returns right away.

$\endgroup$
1
$\begingroup$

Assume that the parameters gc, gm, k, u, w, wm are all real and generic. Then, using Mathematica, you will see that the matrix M is always nonsingular. Namely, the answer is: there is no such w.

This can be confirmed as follows:

$Version
(* "14.2.1 for Mac OS X ARM (64-bit) (March 16, 2025)" *)

det = Factor[Det[M]]

det

{re, im} = ComplexExpand[ReIm[Numerator[det]]]

2

Here, re and im represent the real and imaginary parts of the numeretor of det, respectively.

The condition for a matrix M to be singular is that both re = 0 and im = 0.

For generic parameter, this does not hold.

Solve[re == 0 && im == 0, w]
(* {} *)

The empty list means there is no such w. Note that Solve assumes all parameters except w to be generic.

If you choose the parameters gc, gm, k, u, wm very carefully, there is a chance of getting singular M, i.e. re=im=0. This is possible only when the following relation is satisfied:

Factor[Eliminate[re == 0 && im == 0, w]]

3

$\endgroup$
4
  • $\begingroup$ I think the idea is to find the nongeneric values. $\endgroup$ Commented yesterday
  • $\begingroup$ @DanielLichtblau What you say may be correct, but I cannot judge from the question whether OP has a correct understanding of the situation. $\endgroup$ Commented yesterday
  • $\begingroup$ Choosing gm = gc = 0 satisfies the last expression in the answer above, and for ranges of values of the other parameters yields real w. $\endgroup$ Commented yesterday
  • $\begingroup$ @bbgodfrey Then Assuming[gm == 0 && gc == 0, Solve[re == 0 && im == 0, w]] will give four possible values of w. However, I don't know if OP would be interested in such a special case. $\endgroup$ Commented yesterday
0
$\begingroup$

step 1. Extract the numerator of the determinant

Since the determinant is a rational function in $w$, the zeros come from the numerator polynomial (excluding cancellation with denominator poles).

step 2. Assign numerical values to parameters

If symbolic solutions are not required, fixing numerical values makes solving fast.

step 3. If partial symbolic parameters are needed

If only $w$ is the variable and other parameters remain symbolic, try solving the polynomial equation while avoiding heavy symbolic expansion:

sol = Solve[num == 0, w, Cubics -> False, Quartics -> False]

This returns \texttt{Root} objects which can be numerically evaluated later.

step 4. Plot to locate roots

For numerical parameters, visualize the real and imaginary parts to find good initial guesses

step 5. Complete numerical example

M = {{Aexpr, Bexpr}, {Bexpr, Cexpr}} /. params;
detFun[w0_?NumericQ] := Det[M /. w -> w0];
FindRoot[detFun[w], {w, 1}]

This avoids large symbolic expressions and is much faster.

I'm sorry that I'm not very familiar with the MSE Q&A environment yet, and I don't know how to attach highlighted code block examples. I hope this answer can be of some help to you.

New contributor
Yang Hang is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.