pow | R Documentation |
R_pow()
pow(x,y)
calls R C API ‘Rmathlib’'s R_pow(x,y)
function to compute x^y
or when try.int.y
is true
(as by default), and y
is integer valued and fits into integer
range, R_pow_di(x,y)
.
pow_di(x,y)
with integer y
calls R mathlib's R_pow_di(x,y)
.
pow (x, y, try.int.y = TRUE)
pow_di(x, y)
.pow (x, y)
x |
a numeric vector. |
y |
a numeric or in the case of |
try.int.y |
logical indicating if |
In January 2024, I found (e.g., in ‘tests/pow-tst.R’)
that the accuracy of pow_di()
, i.e., also the C function
R_pow_di()
in R's API is of much lower precision than R's
x^y
or (equivalently) R_pow(x,y)
in R's API, notably on
Linux and macOS, using glib etc, sometimes as soon as y \ge 6
or so.
.pow(x,y)
is identical to pow(x,y, try.int.y = FALSE)
a numeric vector like x
or y
which are recycled to common
length, of course.
Martin Maechler
Base R's ^
“operator”.
set.seed(27)
x <- rnorm(100)
y <- 0:9
stopifnot(exprs = {
all.equal(x^y, pow(x,y))
all.equal(x^y, pow(x,y, FALSE))
all.equal(x^y, pow_di(x,y))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.