What is the efficient way to solve the matrix having a dependency on some varaible f. I have a simple matrix g which is dependent on f. Need to find for what value of f, the determinat of the matrix goes to zero. In reality I am dealing with a problem of size 1000 cross 1000 which is having a dependency on f. I dont want to extract the symbolc determinant, and use NSolve to find the roots which satisfy the Det equatio. This method fails for matrix of large dimensions. I am looking for the methods which is effective to solve this matrix irrespective of matrix dimensions. I have tried a method below, which is not elegant. But this method did not slove my problem.

frange = N[Subdivide[0, 1000, 10000]];
g = {{2*f^2 + 3.6*f^2, 192}, {876, 21.8*f^2 + 33.3*f^2}};
c = Table[
   First@#/Last@# &@SingularValueList[g /. f -> frange[[i]]], {i, 1, 
ListLogLinearPlot[{frange, c}, Joined -> True, PlotRange -> All]

2 Answers 2


Maybe you could use FindRoot? The trick is to know how to differentiate the determinant of a matrix, which is:

$$\frac{d \det (g(x))}{dx} = \det\left(g(x)\right) \ \mathrm{tr}\left(g(x)^{-1}.g'(x)\right)$$

Your example:

g = {{2*f^2 + 3.6*f^2, 192}, {876, 21.8*f^2 + 33.3*f^2}};

In order to avoid expanding out the symbolic determinant, define:

m[f_?NumericQ] = g;
m'[f_?NumericQ] = D[g, f];

Then, use FindRoot:

FindRoot[Det[m[x]], {x, 10}, Jacobian -> {{Det[m[x]]Tr[Inverse[m[x]] . m'[x]]}}]

{x -> 4.83188}


The type of dependence in f is critical here. For your example, it amounts to calculating a generalized eigenvalue.

g = {{2*f^2 + 3.6*f^2, 192}, {876, 21.8*f^2 + 33.3*f^2}};
{A0, A1, A2} = CoefficientArrays[g, f] // Normal;
eigs = Eigenvalues[{A0, -Flatten /@ A2}];

which is such that

Det[g /. f -> Sqrt[eigs[[1]]]]

is numerically zero, which corresponds to the solution in the range you are looking for.

More generally, if you have a single variable f that appears polynomially in the matrix then its determinant is also a polynomial in that variable and you can solve for its roots as in

Solve[Det[g] == 0, f]
  • $\begingroup$ Does this method work for matrix of all dimensions? $\endgroup$ May 8 at 16:12
  • $\begingroup$ Does this method work for matrix of all dimensions? And I didnt understood the second line in your answer. $\endgroup$ May 8 at 16:18
  • $\begingroup$ It works as long as the matrix is square and the dependence on the one variable is linear. Your matrix is linear in f^2, and the second line is extracting the coefficient of the f^2 term, that is A2. $\endgroup$ May 8 at 16:40
  • $\begingroup$ what If some terms are having terms f^3 and some terms f^2, it does not work? $\endgroup$ May 8 at 16:57
  • $\begingroup$ It may, if you are able to restate your dependence as linear by growing your dimensions then you have a generalized eigenvalue problem. But that would have to be studied carefully. More generally, if all you have is one variable and the dependence is polynomial, then the determinant is a polynomial on that variable. In principle, this amounts to finding the roots of a polynomial in a single variable, which should be workable. I will change the answer to have that addressed. $\endgroup$ May 8 at 17:05

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.