VGAM (version 1.0-4)

lerch: Lerch Phi Function

Description

Computes the Lerch transcendental Phi function.

Usage

lerch(x, s, v, tolerance = 1.0e-10, iter = 100)

Arguments

x, s, v

Numeric. This function recyles values of x, s, and v if necessary.

tolerance

Numeric. Accuracy required, must be positive and less than 0.01.

iter

Maximum number of iterations allowed to obtain convergence. If iter is too small then a result of NA may occur; if so, try increasing its value.

Value

Returns the value of the function evaluated at the values of x, s, v. If the above ranges of \(x\) and \(v\) are not satisfied, or some numeric problems occur, then this function will return a NA for those values.

Warning

This function has not been thoroughly tested and contains bugs, for example, the zeta function cannot be computed with this function even though \(\zeta(s) = \Phi(x=1,s,v=1)\). There are many sources of problems such as lack of convergence, overflow and underflow, especially near singularities. If any problems occur then a NA will be returned.

Details

The Lerch transcendental function is defined by $$\Phi(x,s,v) = \sum_{n=0}^{\infty} \frac{x^n}{(n+v)^s}$$ where \(|x|<1\) and \(v \neq 0, -1, -2, \ldots\). Actually, \(x\) may be complex but this function only works for real \(x\). The algorithm used is based on the relation $$\Phi(x,s,v) = x^m \Phi(x,s,v+m) + \sum_{n=0}^{m-1} \frac{x^n}{(n+v)^s} .$$ See the URL below for more information. This function is a wrapper function for the C code described below.

References

Originally the code was found at http://aksenov.freeshell.org/lerchphi/source/lerchphi.c.

Bateman, H. (1953) Higher Transcendental Functions. Volume 1. McGraw-Hill, NY, USA.

See Also

zeta.

Examples

Run this code
# NOT RUN {
s <- 2; v <- 1; x <- seq(-1.1, 1.1, length = 201)
plot(x, lerch(x, s = s, v = v), type = "l", col = "blue", las = 1,
     main = paste("lerch(x, s = ", s,", v =", v, ")", sep = ""))
abline(v = 0, h = 1, lty = "dashed", col = "gray")

s <- rnorm(n = 100)
max(abs(zeta(s) - lerch(x = 1, s = s, v = 1)))  # This fails (a bug); should be 0
# }

Run the code above in your browser using DataCamp Workspace