diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 01f1312085..6ef528cfed 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -196,6 +196,9 @@ \item \code{optimize(f, *)} when \code{f(x)} is not finite says more about the value in its \code{warning} message. It no longer replaces \code{-Inf} by the largest \emph{positive} finite number. + + \item The documentation of \code{gamma} and \code{is.numeric} is more + specific, thanks to the contributors of \PR{18677}. } } diff --git a/src/library/base/man/Special.Rd b/src/library/base/man/Special.Rd index c24f7b410f..9ea56c5bcb 100644 --- a/src/library/base/man/Special.Rd +++ b/src/library/base/man/Special.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/Special.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2022 R Core Team +% Copyright 1995-2025 R Core Team % Distributed under GPL 2 or later \name{Special} @@ -62,7 +62,15 @@ lfactorial(x) gamma function. The gamma function is defined by (\bibcite{Abramowitz and Stegun section 6.1.1, page 255}) \deqn{\Gamma(x) = \int_0^\infty t^{x-1} e^{-t} dt}{\Gamma(x) = integral_0^Inf t^(x-1) exp(-t) dt} - for all real \code{x} except zero and negative integers (when + for all \eqn{x > 0}, from which the recursions \eqn{\Gamma(x+1) = + x\Gamma(x)} and then \eqn{\Gamma(x+n) = (x+n-1)(x+n-2)\cdots x \Gamma(x)} + for all non-negative integers \eqn{n}. Solving for \eqn{\Gamma(x)} and + analytic continuation leads to the expression for non-integer negative real numbers, + \deqn{\Gamma(x) = \frac{\Gamma(x + n)}{(x + n -1) \cdots (x + 1)x}, \ n \in \mathbb{Z}^{+}, -n < x < 0,% + }{\Gamma(x) = \Gamma(x + n)/((x + n -1) ... (x + 1)x), n in N, -n < x < 0,} + see \bibcite{Abramowitz and Stegun (6.1.16 or 6.1.22, page 256)}. + % + The gamma function is not defined for zero and negative integers (when \code{NaN} is returned). There will be a warning on possible loss of precision for values which are too close (within about \eqn{10^{-8}}{1e-8}) to a negative integer less than \samp{-10}. diff --git a/src/library/base/man/numeric.Rd b/src/library/base/man/numeric.Rd index f7af5d2e7a..53b14af79a 100644 --- a/src/library/base/man/numeric.Rd +++ b/src/library/base/man/numeric.Rd @@ -39,7 +39,7 @@ is.numeric(x) function: you can write methods to handle specific classes of objects, see \link{InternalMethods}. It is \strong{not} the same as \code{\link{is.double}}. Factors are handled by the default method, - and there are methods for classes \code{"\link{Date}"}, + and there are methods for classes \code{"\link{complex}"}, \code{"\link{Date}"}, \code{"\link{POSIXt}"} and \code{"\link{difftime}"} (all of which return false). Methods for \code{is.numeric} should only return true if the base type of the class is \code{double} or \code{integer}