Learn R Programming

frmqa (version 0.1-4)

besselK_inc_ite: Approximations of the Incomplete BesselK Function Using an Iterative Algorithm

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 approximates this integral and gives warnings when encountering computational problem or exceptions.

References

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 Function incompleteBesselK in package DistributionUtils 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)

##Severe 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, 0, 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