Learn R Programming

frmqa (version 0.1-5)

besselK_inc_ite: Approximation of the Incomplete BesselK Function Iteratively

Description

Approximates incomplete modified Bessel function using the algorithm provided by Slevinsky and Safouhi (2010) and gives warnings when loss of accuracy or an exception occurs.

Usage

besselK_inc_ite(x, y, lambda, traceIBF = TRUE, epsilon = 0.95, 
      nmax = 120)

Arguments

Details

One of the integral representations of the incomplete Bessel function is given by $$K_{\lambda}(x, y) = \int_1^{\infty}\, e^{-xt -y/t}\,t^{-\lambda-1}\,dt,$$ besselK_inc_ite is the R version of the routine described in Slevinsky and Safouhi (2010) which encounters computional problems when x and y increase. Function besselK_inc_ite detects such problems and gives warnings when they occur.

References

Scott, D (2012) DistributionUtils: Distribution Utilities, R package version 0.5-1, http://CRAN.R-project. org/package=GeneralizedHyperbolic. Slevinsky, R. M., and Safouhi, H (2010) A recursive algorithm for the $G$ transformation and accurate computation of incomplete Bessel functions. Appl. Numer. Math., 60 1411--1417. Kahan, W (1981) Why do we need a foating-point arithmetic standard? http://www.cs.berkeley.edu/ wkahan/ieee754status/why-ieee.pdf.

Examples

Run this code
## "Exact" evaluation are given by Maple 15
options(digits = 16)

## Gives accurate approximations
## x = 0.01, y = 4, lambda = 0, exact value = 2.225 310 761 266 4692
besselK_inc_ite(0.01, 4, 0, traceIBF = FALSE, epsilon = 0.95, nmax = 160)
## x = 1, y = 4, lambda = 2, exact value = 0.006 101 836 926 254 8540
besselK_inc_ite(1, 4, 2, traceIBF = FALSE, epsilon = 0.95, nmax = 160)

## NaN occurs
## x = 1, y = 1.5, lambda = 8, exact value = 0.010 515 920 838 551 3164
besselK_inc_ite(1, 1.5, 8, traceIBF = TRUE, epsilon = 0.95, 
  nmax = 180)

##Loss of accuracy
## x = 14.5, y = 19, lambda = 0, exact value = 9.556 185 644 444 739 5139(-16)
besselK_inc_ite(14.75, 19, 2, traceIBF = TRUE, epsilon = 0.95, nmax = 160)
## x = 17, y = 15, lambda = 1, exact value= 1.917 488 390 220 793 6555(-15)
besselK_inc_ite(17, 15, 1, traceIBF = TRUE, epsilon = 0.95, nmax = 160)

Run the code above in your browser using DataLab