Archived

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

complex pow() and log() etc..

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 this post


Link to post
Share on other sites