logm and expm function
3 ビュー (過去 30 日間)
古いコメントを表示
Hi there,
%If we consider a diagnal matrix defined as:
delta=diag(exp(1i*2*pi*(0:10)/11));
%and we define another matrix C as:
C=diag(1i*2*pi*(0:10)/11);
%so, if we compute this:
D=logm(delta);
%D should be equal to C, right? but the result is not, part of elements in D is equal to C but not all of them. I can't fix this issue.
Many thanks to you!
Charlie
2 件のコメント
Dyuman Joshi
2022 年 9 月 13 日
編集済み: Dyuman Joshi
2022 年 9 月 13 日
Edit - Check Walter Roberson's answer for more details on the question.
In your matrix delta, all terms except for the diagonal terms are 0. And thus using logm() would not be ideal.
delta=diag(exp(1i*2*pi*(0:10)))
Though you can use expm() on C and compare it with delta
C=diag(1i*2*pi*(0:10));
D=expm(C);
isequal(delta,D)
採用された回答
Walter Roberson
2022 年 9 月 13 日
The problem you are running into is that you are assuming that log(exp(X)) == X for all X. However, that is only true for real numbers. For complex numbers, with the sin() going on, values are mapped to the primary branch. exp(2i*pi*N) for integer N is going to involve 1i*sin(2*pi*N) which is going to have a complex part of 0 for all integer N.
format long g
Pi = sym(pi);
%If we consider a diagnal matrix defined as:
delta = diag(exp(1i*2*Pi*(0:10)))
%and we define another matrix C as:
C = diag(1i*2*Pi*(0:10))
%so, if we compute this:
D=logm(delta)
C - D
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!