필터 지우기
필터 지우기

logm and expm function

조회 수: 7 (최근 30일)
mingcheng nie
mingcheng nie 2022년 9월 13일
편집: Torsten 2022년 9월 13일
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
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)))
delta =
1.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 - 0.0000i
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)
ans = logical
1
mingcheng nie
mingcheng nie 2022년 9월 13일
thank you for your answer, I make sense now!

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

채택된 답변

Walter Roberson
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)))
delta = 
%and we define another matrix C as:
C = diag(1i*2*Pi*(0:10))
C = 
%so, if we compute this:
D=logm(delta)
D = 
C - D
ans = 
  댓글 수: 7
mingcheng nie
mingcheng nie 2022년 9월 13일
what if we set
delta=diag(exp(1i*2*pi*(0:10)/11));
then
C=diag(1i*2*pi*(0:10)/11);
as delta vary from 0 to 10/11, we might not get the N is integer, so I think the expm(C) == delta right?
Torsten
Torsten 2022년 9월 13일
편집: Torsten 2022년 9월 13일
expm(diag(v)) = diag(exp(v))
for every vector v.
Here, you have no restrictions.
v = [log(675) log(i) log(-8)];
expm(diag(v))
ans =
1.0e+02 * 6.7500 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0100i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.0800 + 0.0000i
diag(exp(v))
ans =
1.0e+02 * 6.7500 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0100i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.0800 + 0.0000i

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by