Complex icon indicating copy to clipboard operation
Complex copied to clipboard

Logaritm of Negative numbers

Open arian opened this issue 15 years ago • 1 comments

Currently new Complex(-Math.E.pow(2), 0).log() returns 2, but because -Math.E.pow(2) is a negative number it should return 2+pi*i

I have to find out how to calculate the logarithm of negative numbers and the logarithm of complex numbers where the real part is negative.

arian avatar Oct 30 '10 00:10 arian

The Euler formula can be used to derive the complex logarithm function. Just use the argument (the "phi" as you call it in your library) as the imaginary value for the output. Negative numbers have an argument of pi, so that will fix your problem.

For reference, the Euler form of the complex function is log(r e^(ti)) = log(r)+ti, where t is a real number between (-pi, pi] (parentheses mean "not-including", square brackets mean "including").

patrickroberts avatar Sep 11 '14 02:09 patrickroberts