Info

此问题已关闭。 请重新打开它进行编辑或回答。

A bug in Matlab 2009

1 次查看(过去 30 天)
Chienmin
Chienmin 2011-8-6
关闭: MATLAB Answer Bot 2021-8-20
Dear Sir,
I guess there is a bug in MatLab R2009a as the code below.
temp0=[0;1.1;2.2;3.3]; temp1=exp(2*pi*1i*temp0), temp2=exp(2*pi*1i).^temp0
temp1 =
1.000000000000000e+000
8.090169943749471e-001 +5.877852522924736e-001i
3.090169943749462e-001 +9.510565162951540e-001i
-3.090169943749467e-001 +9.510565162951539e-001i
temp2 =
1.000000000000000e+000
1.000000000000000e+000 -2.694222958124178e-016i
1.000000000000000e+000 -5.388445916248355e-016i
1.000000000000000e+000 -8.082668874372531e-016i
Obviously, the result of temp2 is diferent from that of temp1.
Straggely, if we replace 2*pi by pi, then we have the identically correct answers.
temp0=[0;1.1;2.2;3.3]; temp1=exp(pi*1i*temp0), temp2=exp(pi*1i).^temp0
temp1 =
1.000000000000000e+000
-9.510565162951535e-001 -3.090169943749477e-001i
8.090169943749471e-001 +5.877852522924736e-001i
-5.877852522924735e-001 -8.090169943749472e-001i
temp2 =
1.000000000000000e+000
-9.510565162951535e-001 -3.090169943749477e-001i
8.090169943749471e-001 +5.877852522924736e-001i
-5.877852522924735e-001 -8.090169943749472e-001i

回答(1 个)

Pierre
Pierre 2011-8-6
You imply the property exp(x*y) = exp(x)^y , which surely is true for real numbers, would also apply for complex numbers; but that is in general not true!
Addressing your intuition that you wrongly expect temp1 and temp2 to be equal on the first example:
First, do you agree that 2*pi*i*2.2 is no integer multiple of 2*pi*i, and therefore exp(2*pi*i*2.2) cannot equal 1 ?
And do you agree that, on the other hand, exp(2*pi*i) = 1 and 1^2.2 remains still 1?

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by