[R] Inf +1i vs 1+Inf*1i
Robin Hankin
r.hankin at soc.soton.ac.uk
Wed Apr 13 11:42:04 CEST 2005
On Apr 13, 2005, at 09:40 am, Martin Maechler wrote:
> Actually, the problem comes from "Inf * 1i" (or 1i * Inf)
> and the
> 0 * Inf |-> NaN
> which of course is `correct' in general, but a bit undesirable
> in the rule
>
> (a + bi) * (c + di) = (ac - bd) + (ad + bc)i
thanks for this Martin.
Now I see what is going on, I wouldn't describe this as "undesirable"
because
"(1+0i) * (0 + Inf i)" depends on the behaviour of the infinite limit
in the second bracket compared with the zero limit in the first.
To wit, f() and g() both calculate 1*(Inf i):
> f <- function(n){(1+1i/sqrt(n))*(0+n*1i)}
> g <- function(n){(1+1i/n)*(0+sqrt(n)*1i)}
> f(1e8)
[1] -10000+1e+08i
> g(1e8)
[1] -1e-04+10000i
>
So perhaps it's unreasonable to expect complex arithmetic to guess what
I want.
very best wishes
rksh
Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743
More information about the R-help
mailing list