besselK_inc_ite: Approximation of the Incomplete BesselK Function Iteratively

Description Usage Arguments Details Note Author(s) References Examples

View source: R/frmqa.R

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

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

Arguments

x

Argument, x > 0.

y

Argument, y > 0.

lambda

Order of the BesselK function.

traceIBF

Logical, tracks the approximation process if TRUE.

epsilon

Determines approximation accuracy which equals machine accuracy raised to the power of epsilon.

nmax

Integer. Maximum number of iterations required.

Details

One of the integral representations of the incomplete Bessel function is given by

K_{λ}(x, y) = \int_1^{∞}\, e^{-xt -y/t}\,t^{-λ-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.

Note

A C++ version of this function will be added in due course.

Author(s)

Thanh T. Tran frmqa.package@gmail.com

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## "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
## Not run: besselK_inc_ite(1, 1.5, 8, traceIBF = TRUE, epsilon = 0.95, 
  nmax = 180)
## End(Not run)

##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)

frmqa documentation built on May 2, 2019, 12:22 p.m.