Learn R Programming

DPQ (version 0.4-3)

logcf: Continued Fraction Approximation of Log-Related Power Series

Description

Compute a continued fraction approximation to the series (infinite sum) $$\sum_{k=0}^\infty \frac{x^k}{i +k\cdot d} = \frac{1}{i} + \frac{x}{i+d} + \frac{x^2}{i+2*d} + \frac{x^3}{i+3*d} + \ldots$$

Needed as auxiliary function in log1pmx() and lgamma1p().

Usage


logcfR (x, i, d, eps, maxit = 10000L, trace = FALSE)
logcfR.(x, i, d, eps, maxit = 10000L, trace = FALSE)
logcf  (x, i, d, eps, trace = FALSE)

Arguments

x

numeric vector, "mpfr" now works, too.

i

positive numeric

d

non-negative numeric

eps

positive number, the convergence tolerance.

maxit

a positive integer, the maximal number of iterations or terms in the truncated series used.

trace

logical (or non-negative integer in the future) indicating if (and how much) diagnostic output should be printed to the console during the computations.

Value

a numeric-alike vector with the same attributes as x.

Details

logcfR.():

the first pure R version where the iterations happen vectorized in x, i.e., relatively fast; however convergence and rescaling are a “group decision” which is really suboptimal for reproducibility or careful comparisons.

logcfR():

a pure R version where each x[i] is treated separately, hence “properly” vectorized, but slowly so. Now recommended when x is an "mpfr"-number vector.

logcf():

only for numeric x, calls into (a clone of) R's own (non-API currently) logcf() C Mathlib function.

See Also

lgamma1p, log1pmx, and pbeta, whose prinicipal algorithm has evolved from TOMS 708.

Examples

Run this code
# NOT RUN {
<!-- %% FIXME:  logcfR() ! -->
# }
# NOT RUN {
l32 <- curve(logcf(x, 3,2, eps=1e-7), -3, 1)
abline(h=0,v=1, lty=3, col="gray50")
plot(y~x, l32, log="y", type = "o", main = "logcf(*, 3,2)  in log-scale")
# }

Run the code above in your browser using DataLab