#### Archived

This topic is now archived and is closed to further replies.

# Complex powers using C++'s complex template

This topic is 6025 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all! I''m working on my complex symbolic math software and I''m confused about complex power. Actually, only about powers in this form (-a)^(c+bi), a > 0 It always returns me complex number of non defined numbers - [-1.IND, -1.IND]. Does anybody know where might be the problem? I''m using MS C++ .NET beta 2 -------- Dave

##### Share on other sites
The usual way to take a complex exponent is to use the formula

az = elog(a^z) = e z log a

a in your case is a negative number and your compiler might be having trouble with this. After all it''s (a) Microsoft (b) beta and (c) .NET

If a is negative then log(a) = iPI + log|a|.

##### Share on other sites
I'm going to follow up on this post, but I will warn you that this does not appear to be a game development related question. At least it is not obvious from your brief post. Please do not make it a habit to ask non-game-development question here. The bandwidth on this site is ear-marked for the game-development community. I'll give you the benefit of the doubt since you've been a member for a very long time, .

sQuid has the right idea, but there's a bug in his derivation . The first line of formulas assumes that log(az) is the same as z*log(a), which is not true. Its easy to prove this is wrong. However, the end result is correct,

az = ez*log(a)

sQuid is correct on the definition of log(a) when a is negative.

I'll also comment that "log" is the natural log (log-based e).

I'll supplement sQuid's post:

z = c + bi

so,

ez = ecebi

By definition, by the "Euler formula",

ebi = cos(b)+ i*sin(b)

Then,

ez = ec*(cos(b) + i*sin(b))

I'll note that if a is a positive real number, then log(a) is just a constant multiplier to c an b. The final exponent az is quite easy to find. If a is negative, then log(a) is the complex number given by sQuid and so z*log(a) is a complex number times a complex number. Again, easy to do, but just don't forget that step. Then plug the result into the Euler formula.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

[edited by - grhodes_at_work on April 22, 2002 12:03:51 PM]

##### Share on other sites
Thanks a lot for your replies.
I found it very useful.

--------
Dave

##### Share on other sites
quote:
The first line of formulas assumes that log(az) is the same as z*log(a), which is not true

Really? Here is my derivation which I can''t find a mistake in

Let x = log(az)

exponentiating both sides

ex = az

Raising both sides to the power of 1/z

ex/z = az*(1/z) = a

taking logs again

x/z = log(a)

so x = z*log(a)

##### Share on other sites
sQuid,

I must apologize. You are correct, and my statement that you made a mistake was in fact....the mistake. I''m not sure what I was thinking there.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 90
• 11
• 10
• ### Forum Statistics

• Total Topics
632973
• Total Posts
3009620
• ### Who's Online (See full list)

There are no registered users currently online

×