Basic power rule ((a^b)^c = a^(b*c)) does not work

1 次查看(过去 30 天)
Just cracked down a large problem in my code to a strange phenomenon. A very simple power rule doesn't seem to work here.
b = 5i; %complex, this should have something to do with it
c = 0.1; %for intergers it seems to work
x1 = exp(b)^c;
x2 = exp(b*c);
x1 =
0.9918 - 0.1280i
x2 =
0.8776 + 0.4794i
Shouldn't they be equal?
I just do not unterstand..
  2 个评论
Greg Dionne
Greg Dionne 2019-2-1
编辑:Greg Dionne 2019-2-1
I can't tell if this is homework or not, so here's a thought experiment:
At what value of x does the following print different values for your two expressions?
for x=0.01:.01:5;
y = 0.5/x; % make sure x*y = 0.5
expression1 = exp(1i*x)^y;
expression2 = exp(1i*x*y);
fprintf('%f: %f + %fi ?= %f + %fi\n',x, ...
real(expression1), imag(expression1), ...
real(expression2), imag(expression2));
end
Andreas Dorner
Andreas Dorner 2019-2-1
No, it's not homework, this is was a problem i encountered in academic research. I wanted to get rid of one power to speed up my code running on gpu.
I see where you're going with this, thank you! exp(1i*2pi) is starting over again at the unit circle. I didn't see that coming, i feel kinda stupid now. But I wonder if a can use that knowledge somehow.
Thank you very much for your insight. Have a nice day!

请先登录,再进行评论。

采纳的回答

Luna
Luna 2019-2-1
编辑:Luna 2019-2-1
By the definition Euler's equation: z = x + iy means
So the two things might be different:
and
x2 = exp(b*c) is equal to exp(c)^b actually.
equals
equals also equals
But those two above are not equal.
  2 个评论
Walter Roberson
Walter Roberson 2019-2-1
(I notice the latex is cut off at the top of each section. I have reported this to Mathworks a second ago.)

请先登录,再进行评论。

更多回答(1 个)

James Tursa
James Tursa 2019-2-1
编辑:James Tursa 2019-2-1
This has been discussed in this forum before. Raising complex numbers to a power is a multi-valued operation. MATLAB picks one of those results, which may or may not agree with the result you get by rearranging the operations. E.g.,
>> b = 5i;
>> c = 0.1;
>> exp(b)
ans =
0.283662185463226 - 0.958924274663138i
>> exp(b+2*pi*i) % You can add 2*pi to get same result
ans =
0.283662185463226 - 0.958924274663139i
>> exp(b+4*pi*i) % You can add 4*pi to get same result
ans =
0.283662185463226 - 0.958924274663139i
>> exp(b+18*pi*i) % In general, you can add k*2*pi
ans =
0.283662185463224 - 0.958924274663139i
>>
>> exp(b)^c
ans =
0.991778467700342 - 0.127966679280045i % The MATLAB answer for this expression
>> exp(b*c)
ans =
0.877582561890373 + 0.479425538604203i % This particular rearrangement doesn't match
>> exp((b+18*pi*i)*c)
ans =
0.991778467700342 - 0.127966679280045i % But this one does
You can probably look at the doc to see the rules for how MATLAB picks the result for these mutli-valued issues. But the bottom line is if you have code that depends on multi-valued calculations like this, you need to account for it in your code logic. MATLAB isn't going to know which one you want picked, and you shouldn't expect it to.
  2 个评论
Andreas Dorner
Andreas Dorner 2019-2-2
Thank you first of all. I see the problem.
But why does exp((b+18*pi*i)*c) work? 18pi seems a bit arbitrary
Stephen23
Stephen23 2019-2-2
"18pi seems a bit arbitrary"
It is entirely arbitrary. That is exactly the point.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by