# Looking for a efficient way of solving a matrix which is function of some variable

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,
Length[frange]}];
ListLogLinearPlot[{frange, c}, Joined -> True, PlotRange -> All]
PeakDetect[c]


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)$$

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[]]]


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]

• Does this method work for matrix of all dimensions? May 8 at 16:12
• Does this method work for matrix of all dimensions? And I didnt understood the second line in your answer. May 8 at 16:18
• 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. May 8 at 16:40
• what If some terms are having terms f^3 and some terms f^2, it does not work? May 8 at 16:57
• 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. May 8 at 17:05