4 views (last 30 days)

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..

Luna
on 1 Feb 2019

Edited: Luna
on 1 Feb 2019

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.

Walter Roberson
on 1 Feb 2019

Sign in to comment.

James Tursa
on 1 Feb 2019

Edited: James Tursa
on 1 Feb 2019

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.

Stephen Cobeldick
on 2 Feb 2019

"18pi seems a bit arbitrary"

It is entirely arbitrary. That is exactly the point.

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Direct link to this comment

https://es.mathworks.com/matlabcentral/answers/442709-basic-power-rule-a-b-c-a-b-c-does-not-work#comment_666829

⋮## Direct link to this comment

https://es.mathworks.com/matlabcentral/answers/442709-basic-power-rule-a-b-c-a-b-c-does-not-work#comment_666829

## Direct link to this comment

https://es.mathworks.com/matlabcentral/answers/442709-basic-power-rule-a-b-c-a-b-c-does-not-work#comment_666837

⋮## Direct link to this comment

https://es.mathworks.com/matlabcentral/answers/442709-basic-power-rule-a-b-c-a-b-c-does-not-work#comment_666837

Sign in to comment.