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 at 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 at 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]]
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 at gmail.com> Sent: Friday, September 6, 2024 1:12 AM To: Duncan Murdoch <murdoch.duncan at gmail.com> Cc: Leo Mada <leo.mada at syonic.eu>; r-help at r-project.org <r-help at 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 at gmail.com<mailto:murdoch.duncan at 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+InfiThere'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 at r-project.org<mailto:R-help at 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]]
I expect that atan(1i) = (0 + infinity i) and that atan(1i)/5 = (0 + infinity i)/5 = (0 + infinity i). Here's what I get in C: (0,1) = (0, 1) atan((0,1)) = (0, inf) atan((0,1))/5 = (0, inf) Note the difference between I*infinity = (0,1)*infinity (0*infinity,1*infinity) = (NaN,infinity) and (0,infinity)/5 = (0/5,infinity/5) = (0,infinity). The former involves multiplying 0 by infinity, which yields NaN. The latter does not.> complex(1,0,Inf)*2[1] NaN+Infi There is no good reason for this. 0*2 is 0, not NaN. In IEEE arithmetic, multiplying or dividing a complex number by a real number is NOT the same as multiplying or dividing by the complex version of that real number. (0,Inf) * 2 = (0*2, Inf*2) = (0, Inf). (0,Inf) * (2,0) = (0*2 - Inf*0, 0*0 + Inf*2) = (NaN, Inf). There really truly is a bug here, and it is treating R*Z, Z*R, and Z/R as if they were the same as W*Z, Z*W, and Z/W where W = complex(1,R,0). On Fri, 6 Sept 2024 at 10:12, Bert Gunter <bgunter.4567 at gmail.com> wrote:> > 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 at 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 at 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 at 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.