Jump to content
  • Advertisement

Archived

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

exa_einstein

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.

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

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


Link to post
Share on other sites
Advertisement
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 this post


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


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!