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

2024-09-05 Thread Richard O'Keefe
The thing is that real*complex, complex*real, and complex/real are not "complex arithmetic" in the requisite sense. The complex numbers are a vector space over the reals, and complex*real and real*complex are vector*scalar and scalar*vector. For example, in the Ada programming language, we have fu

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

2024-09-05 Thread Richard O'Keefe
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,in

[R] effects() extractor for a quantile reqression object: error message

2024-09-05 Thread Christopher W. Ryan via R-help
I'm using quantreg package version 5.98 of 24 May 2024, in R 4.4.1 on Linux Mint. The online documentation for quantreg says, in part, under the description of the rq.object, "The coefficients, residuals, and effects may be extracted by the generic functions of the same name, rather than by the $

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

2024-09-05 Thread Bert Gunter
> x <- complex(imag = Inf) > x [1] 0+Infi > x*1 [1] NaN+Infi > x+0 [1] 0+Infi R does the addition and subtraction "coordinatewise"; the C library handles everything else. This results in 2 different ways the point at infinity is printed. (Correction requested if this is wrong) Bert On Thu, Sep

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

2024-09-05 Thread Duncan Murdoch
On 2024-09-05 6:12 p.m., Leo Mada wrote: Dear Duncan, Here is also the missing information: R version 4.4.1 (2024-06-14 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 10 x64 (build 19045) Regarding the results: atan(1i) # 0+Infi Re(atan(1i)) # 0 Im(atan(1i)) #  Inf 0 + Inf i is

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

2024-09-05 Thread Jeff Newmiller via R-help
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.

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

2024-09-05 Thread Bert Gunter
> 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 wrote: > Dear Bert, > > These be

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

2024-09-05 Thread Leo Mada via R-help
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 num

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

2024-09-05 Thread Bert Gunter
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 wrote: > On 2024-09-05 4:23 p.m., Leo Mada via R-help wrote: > > Dear R Users, > > > > Is this desired behaviour? > > I

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

2024-09-05 Thread Duncan Murdoch
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

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

2024-09-05 Thread Bert Gunter
What version of R are you using and on what platform? I get: > atan(1i) [1] 0.7853982+Infi > atan(1i)/5 [1] NaN+Infi on: R version 4.4.1 (2024-06-14) Platform: aarch64-apple-darwin20 Running under: macOS Sonoma 14.6.1 -- Bert On Thu, Sep 5, 2024 at 1:23 PM Leo Mada via R-help wrote: > Dear R

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

2024-09-05 Thread Leo Mada via R-help
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 were some changes in handling of complex numbers. But it looks like a bug. Sincerely, Leonard [[alternative HTML version deleted]] __

Re: [R] lattice log scale labels.

2024-09-05 Thread Gerrit Draisma
Thanks Greg and Bert for solving my problem. This gives what I want: myticks <- 2^(3*(0:11)) mylabels <- parse(text=paste0("2^",log2(myticks))) xyplot(c+t+u~n,data=x,type="b", xlab="Size", ylab="Number of tangles", scales=list(x=list(at=4*(1:9)),y=list(log=2,at=myticks,labels=

Re: [R] lattice log scale labels.

2024-09-05 Thread Bert Gunter
Do the "at" and "labels" components of the "scales" list argument to xyplot not do what you want? Cheers, Bert On Thu, Sep 5, 2024 at 4:05 AM Gerrit Draisma wrote: > Dear R-helpers, > > In the plot below I would like to have labels at positions 2^(3*(0:10)), > and keep the labels in the exponen

Re: [R] Calculation of VCV matrix of estimated coefficient

2024-09-05 Thread Gabor Grothendieck
sigma(model)^2 will give the correct MSE. Also note that your model matrix has intercept at the end whereas vcov will have it at the beginning so you will need to permute the rows and columns to get them to be the same/ On Wed, Sep 4, 2024 at 3:34 PM Daniel Lobo wrote: > > Hi, > > I am trying to

[R] lattice log scale labels.

2024-09-05 Thread Gerrit Draisma
Dear R-helpers, In the plot below I would like to have labels at positions 2^(3*(0:10)), and keep the labels in the exponential format. I tried using yscale.components.default. *This* gives the right format of the labels: > yscale.components.default(lim= c(0,30),log=2) $num.limit [