How to find a complex root from the determinate of a matrix?

조회 수: 2 (최근 30일)
shane
shane 2012년 2월 7일
편집: Alex 2013년 10월 4일
Hi everyone,
Im having a trouble that can be described into two steps:
1)Im having a square complex matrix with unknown x.
2)I need to find x such that the determine of the matrix is zero.
Im trying to separate the solution into real and imag part and solve:
Function detM = detMcal(x,a,delta,L)
complexX = complex(x(1:2:end), x(2:2:end));
complexY = det(Matrix(x,a,delta,L))
detM = [real(complexY); imag(complexY)];
end
and
x = fsolve(@(x) detMcal(x,a,delta,L),[1,1]);
solution = complex(x(1:2:end), x(2:2:end))
But the program is not working. Is my code wrong or are there any better method?
Many Thanks.

답변 (2개)

Dr. Seis
Dr. Seis 2012년 2월 8일
Here is another example:
>>a = complex(randn(1),randn(1));
b = complex(randn(1),randn(1));
c = complex(randn(1),randn(1));
d = complex(randn(1),randn(1));
e = complex(randn(1),randn(1));
f = complex(randn(1),randn(1));
g = complex(randn(1),randn(1));
i = complex(randn(1),randn(1));
>> x = fsolve(@(x)det([a,b,c;d,e,f;g,x,i]),0)
Optimization terminated: first-order optimality is less than options.TolFun.
x =
-2.1461 - 1.9256i
>> M = [a b c; d e f; g x i];
>> det(M)
ans =
2.4603e-08 - 2.9054e-09i
>> x = (g*(b*f-c*e) + i*(a*e-b*d))/(a*f-d*c)
x =
-2.1461 - 1.9256i
>> M = [a b c; d e f; g x i];
>> det(M)
ans =
-1.0025e-15 - 5.6272e-16i
Clearly, the version that does not use "fsolve" is giving an answer that is closer to 0. However, setting the "TolFun" to something different will allow "fsolve" to run more iterations and converge to a more optimal solution. Obviously you wouldn't actually have to define "a" through "i" and construct a matrix as I did above, you would just define the matrix with all of its complex values and then stick an "x" for the element you want to solve for. Or are you planning on reading in these values from another source?
  댓글 수: 3
shane
shane 2012년 2월 8일
By the way, is this similar the method you did or it will give a different solution:
Beta_real = fzero('detMcal_Real',stBeta1,[],a,delta,L)
Beta_Imag = fzero('detMcal_Imag',stBeta2,[],a,delta,L)
bta = complex(Beta_real,Beta_Imag)
%%%where function detMcal_Real and detMcal_Imag find the real and imaginary part of the determinate respectively.
Dr. Seis
Dr. Seis 2012년 2월 8일
"fzero" will probably work, but is designed more for a different application. As far as what the error is, can you provide an example of what "bta", "a", "delta", "L" and/or the result of "Matrix(bta,a,delta,L)" would be?
I guess I am unsure of what you are doing when you break up the problem into real and imaginary parts since if you had a complex matrix "A", then det(A) does not necessarily equal det(real(A)) + i*det(imag(A))

댓글을 달려면 로그인하십시오.


Dr. Seis
Dr. Seis 2012년 2월 7일
You are trying to do the following, but for almost any MxM matrix and any location of x within that matrix:
Example:
M = [a b c; d e f; g x i];
We need -
0 = det(M) = g*(b*f-c*e) - x*(a*f-d*c) + i*(a*e-b*d)
Done at the command line -
>> a = complex(randn(1),randn(1));
>> b = complex(randn(1),randn(1));
>> c = complex(randn(1),randn(1));
>> d = complex(randn(1),randn(1));
>> e = complex(randn(1),randn(1));
>> f = complex(randn(1),randn(1));
>> g = complex(randn(1),randn(1));
>> i = complex(randn(1),randn(1));
>> x = (g*(b*f-c*e) + i*(a*e-b*d))/(a*f-d*c);
>> M = [a b c; d e f; g x i]
M =
2.7694 + 0.1576i 3.0349 + 0.9572i -0.0631 + 0.8003i
-0.2050 + 0.4218i 1.4897 + 0.7922i 1.4172 + 0.6557i
-1.2075 + 0.8491i 0.6899 + 1.2400i 1.6302 + 0.6787i
>> det(M)
ans =
3.3931e-15 - 3.7396e-16i
  댓글 수: 2
Dr. Seis
Dr. Seis 2012년 2월 7일
I just want to confirm before I look into this further.
shane
shane 2012년 2월 8일
Hi Grant,
Thanks for the reply.
I forget to mention that the matrix is dynamics. It can be 8X8 12X12 or even bigger which is depended on user input.
Is there a certain way to find equation for x?
Many Thanks.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by