Bug 14471 - log of complex zero inconsistently specified
Summary: log of complex zero inconsistently specified
Alias: None
Product: R
Classification: Unclassified
Component: Analyses (show other bugs)
Version: R 2.12.1
Hardware: ix86 (32-bit) Windows 64-bit
: P5 trivial
Assignee: R-core
Depends on:
Reported: 2011-01-11 22:49 UTC by Richard Cotton
Modified: 2011-01-12 12:35 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Richard Cotton 2011-01-11 22:49:11 UTC
With no base argument log of complex zero is

> log(0i) 
[1] -Inf+0i 


> log(0i, ) 
[1] -Inf+NaNi

Ideally, the same answer should be given in both cases.
Comment 1 Brian Ripley 2011-01-12 12:26:26 UTC
By the definition log(x,b) = log(x)/log(b)

x <- log(0i) # -Inf+0i
x/log(exp(1)+0i) # -Inf+NaNi
x/log(exp(1))    # same
x/1              # same

That's odd, but as far as I can see is being done by the platform's C99 complex arithmetic and not R.
Comment 2 Brian Ripley 2011-01-12 12:35:10 UTC
I should have said 'odd but correct'.  Consider

x <- -Inf+0i
y <- 1

Then the imaginary part of the result is 
x.r*y.i + x.i*y.r = -Inf*0 + 0*1 = NaN.