Skip to content

Commit

Permalink
describe gamma()`s behavior for negatives // mention that <complex> d…
Browse files Browse the repository at this point in the history
…oes not fulfill is.numeric()

git-svn-id: https://svn.r-project.org/R/trunk@87715 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Feb 12, 2025
1 parent fa73948 commit 8b6c4d6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/library/base/man/Special.Rd
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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}.
Expand Down
2 changes: 1 addition & 1 deletion src/library/base/man/numeric.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 8b6c4d6

Please sign in to comment.