#### Archived

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

# complex pow() and log() etc..

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

## Recommended Posts

Does somebody know any good and fast algorhitm for function complex pow(complex a, [ complex/double ] b) (or how to JUST COMPUTE power of a complex number) ... ln(.. ... log(... ..sqrt.....etc.etc.etc... thank you exa_einstein

##### Share on other sites
The C++ language includes these functions. <complex> includes the complex class as well as the functions.

##### Share on other sites
OK, two problems:
1) I don''t have < complex >
2) I want source of that function

maybe I should find somebody who will post link for some complex stuff (I''ve googled and haven''t find anything)

##### Share on other sites
You can derive it if you know Euler's formula:

e^(i*theta)=cos theta + i*sin theta

To derive:
Exponential
e^z=e^Re(z)*(cos(Im(z))+i*sin(im(z)))

Logarithm
ln(y)=x
y=e^x
=e^Re(x)*(cos(Im(x))+i*sin(im(x)))

Therefore:
Re(y)=e^Re(x)*cos(Im(x))
Im(y)=e^Re(x)*sin(im(x))
e^2*Re(x)=Re(y)^2+Im(y)^2=|y|^2
Re(x)=ln(|y|)
Im(x)=arccos(Re(y)/|y|)=arcsin(Im(y)/|y|)
You need to check this I am not sure it is correct.
I defined Im(x) in two different ways because sometimes one is undefined or not the one you want (ln is multivalued in the compex plain).

Arbitrary power
x^y
=e^(y*ln(x))
Which can be done using above definitions and complex multiplicaiton.

EDIT: Here are some tips on how to do others youi mentioned:
Square root
Same as arbitrary power with y=0.5

Logarithm Base-a
loga(x)=ln(x)/ln(a)

[edited by - sadwanmage on November 12, 2003 5:52:14 PM]

##### Share on other sites
coool ok thank you. I will try to use it correctly...

##### Share on other sites
Mathworld''s listing may also be useful.

http://mathworld.wolfram.com/ComplexNumber.html

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633660
• Total Posts
3013221
×