[R] BUG: atan(1i) / 5 = NaN+Infi ?

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Fri Sep 6 00:38:33 CEST 2024


> complex(real = 0, imaginary = Inf)
[1] 0+Infi

> Inf*1i
[1] NaN+Infi

>> complex(real = 0, imaginary = Inf)/5
[1] NaN+Infi

See the Note in ?complex for the explanation, I think.  Duncan can correct
if I'm wrong.

-- Bert

On Thu, Sep 5, 2024 at 3:20 PM Leo Mada <leo.mada using syonic.eu> wrote:

> Dear Bert,
>
> These behave like real divisions/multiplications:
> complex(re=Inf, im = Inf) * 5
> # Inf+Infi
> complex(re=-Inf, im = Inf) * 5
> # -Inf+Infi
>
> The real division / multiplication should be faster and also is well
> behaved. I was expecting R to do the real division/multiplication on a
> complex number. Which R actually does for these very particular cases; but
> not when only Im(x) is Inf.
>
> Sincerely,
>
> Leonard
>
> ------------------------------
> *From:* Bert Gunter <bgunter.4567 using gmail.com>
> *Sent:* Friday, September 6, 2024 1:12 AM
> *To:* Duncan Murdoch <murdoch.duncan using gmail.com>
> *Cc:* Leo Mada <leo.mada using syonic.eu>; r-help using r-project.org <
> r-help using r-project.org>
> *Subject:* Re: [R] BUG: atan(1i) / 5 = NaN+Infi ?
>
> Perhaps
>
> > Inf*1i
> [1] NaN+Infi
>
> clarifies why it is *not* a bug.
> (Boy, did that jog some long dusty math memories :-)  )
>
> -- Bert
>
> On Thu, Sep 5, 2024 at 2:48 PM Duncan Murdoch <murdoch.duncan using gmail.com>
> wrote:
>
> On 2024-09-05 4:23 p.m., Leo Mada via R-help wrote:
> > Dear R Users,
> >
> > Is this desired behaviour?
> > I presume it's a bug.
> >
> > atan(1i)
> > # 0+Infi
> >
> > tan(atan(1i))
> > # 0+1i
> >
> > atan(1i) / 5
> > # NaN+Infi
>
> There's no need to involve atan() and tan() in this:
>
>  > (0+Inf*1i)/5
> [1] NaN+Infi
>
> Why do you think this is a bug?
>
> Duncan Murdoch
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list