atan(1i) -> 0 + Inf i complex(1/5) -> 0.2 + 0i atan(1i) -> (0 + Inf i) * (0.2 + 0i) -> 0*0.2 + 0*0i + Inf i * 0.2 + Inf i * 0i infinity times zero is undefined -> 0 + 0i + Inf i + NaN * i^2 -> 0 + 0i + Inf i - NaN -> NaN + Inf i
I am not sure how complex arithmetic could arrive at another answer. I advise against messing with infinities... use atan2() if you don't actually need complex arithmetic. On September 5, 2024 3:38:33 PM PDT, Bert Gunter <bgunter.4...@gmail.com> wrote: >> 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.m...@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.4...@gmail.com> >> *Sent:* Friday, September 6, 2024 1:12 AM >> *To:* Duncan Murdoch <murdoch.dun...@gmail.com> >> *Cc:* Leo Mada <leo.m...@syonic.eu>; r-help@r-project.org < >> r-help@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.dun...@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@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]] > >______________________________________________ >R-help@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. -- Sent from my phone. Please excuse my brevity. ______________________________________________ R-help@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.