MATLAB: Matlab determinant equation solver

determinatmathematicsmatlab function

Hi, i would like to solve det (I+lambda*M)=0 (not eigenvalue problem) where lambda is complex number and M has 792 3×3 matrix, please can you advise me code to do it?
Thanks beforehand

Best Answer

Just for kicks, I assume that you really have 792 such 3x3 problems. JUST USE A LOOP. Could you convert this into a cell array of 3x3 matrices? Well, yes. Then you could just use cellfun. Not a problem either way, nor would the code written using cellfun be essentially any better or faster to run. cellfun is just an implicit, internally implemented loop. And the time required for loop over 792 3x3 arrays is quite minimal. So either way you do it is the same.
Next, to your claim this is not an eigenvalue problem. False. It is. With a twist.
Suppose you want to solve the problem
det(I + lambda*M) = 0
where M is a 3x3 matrix? Any nxn matrix applies too, of course.
First, what is the determinant det(k*A), where A is a square 3x3 matrix?
det(k*A) = k^3 *det(A)
For an nxn matrix, we would just have k^n*det(A).
go back and look at your problem.
det(I + lambda*M) = 0
You wish to solve for lambda, suc that this expression is zero. As long as lambda is not zero, then you can divide by lambda^3. And we just showed that we can distribute that into the matrix inside the determinant. So we can write the problem as:
det(I*1/lambda + M) = 0
AND THAT IS AN EIGENVALUE PROBLEM. Solve for the eigenvalues of the 3x3 matrix M. Then invert them, and multiply by -1, since the eigenvalues of a system solve the problem:
det(A - lambda*I) = 0
The only case where you have a problem is then M is singular, in which case one or more of the eigenvalues of M is zero.
Related Question