fn_gs: Compute Inverse Laplace transform using Gaver-Stehfest...

Description Usage Arguments Value Examples

View source: R/lib_gaver_stehfest.R

Description

Note Gaver-Stehfest algorithm is theoretically convergent but practically high precision arithmetic is required. This is not achieved in R as R4.0+ uses "long-double" in C, which is 64bit floating point. As a result, using high n would yield results divergent to infinity. Therefore, small n should be used. Using default arguments, values for different n would be printed along with a plot which assists in determining an appropriate n.

Usage

1
fn_gs(Fn, x, n = 10, try_n = TRUE, plot = TRUE, ...)

Arguments

Fn

Function. Function to be inversed.

x

Numeric (positive). Location of the function to be approximated.

n

Numeric. Number of terms used in the Gaver-Stehfest algorithm.

try_n

Logical. Whether all n values up to n are evaluated. Useful to determine n.

plot

Logical. In case try_n is TRUE, a plot is also generated.

...

Other arguments to be passed to Fn. (".k123456" is reserved. An event of argument crash should be unlikely...)

Value

Numeric. Vector of length n if try_n is TRUE (Default). Otherwise, length is 1.

Examples

1
2
3
4
5
6
library(pruin)

## constant function
Fconst <- function(x,k)k/x

fn_gs(Fconst,2,n=15,k=2)

haydo1117/pruin documentation built on Feb. 12, 2022, 11:08 a.m.