Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_sum_invlaplace_weeks_eval (c06lc)

## Purpose

nag_sum_invlaplace_weeks_eval (c06lc) evaluates an inverse Laplace transform at a given point, using the expansion coefficients computed by nag_sum_invlaplace_weeks (c06lb).

## Syntax

[finv, ifail] = c06lc(t, sigma, b, acoef, errvec, 'm', m)
[finv, ifail] = nag_sum_invlaplace_weeks_eval(t, sigma, b, acoef, errvec, 'm', m)

## Description

nag_sum_invlaplace_weeks_eval (c06lc) is designed to be used following a call to nag_sum_invlaplace_weeks (c06lb), which computes an inverse Laplace transform by representing it as a Laguerre expansion of the form:
 $f~ t = eσt ∑ i=0 m-1 ai e -bt/2 Li bt , σ > σO , b > 0$
where ${L}_{i}\left(x\right)$ is the Laguerre polynomial of degree $i$.
This function simply evaluates the above expansion for a specified value of $t$.
nag_sum_invlaplace_weeks_eval (c06lc) is derived from the function MODUL2 in Garbow et al. (1988)

## References

Garbow B S, Giunta G, Lyness J N and Murli A (1988) Algorithm 662: A Fortran software package for the numerical inversion of the Laplace transform based on Weeks' method ACM Trans. Math. Software 14 171–176

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{t}$ – double scalar
The value $t$ for which the inverse Laplace transform $f\left(t\right)$ must be evaluated.
2:     $\mathrm{sigma}$ – double scalar
3:     $\mathrm{b}$ – double scalar
4:     $\mathrm{acoef}\left({\mathbf{m}}\right)$ – double array
5:     $\mathrm{errvec}\left(8\right)$ – double array
sigma, b, m, acoef and errvec must be unchanged from the previous call of nag_sum_invlaplace_weeks (c06lb).

### Optional Input Parameters

1:     $\mathrm{m}$int64int32nag_int scalar
Default: the dimension of the array acoef.
sigma, b, m, acoef and errvec must be unchanged from the previous call of nag_sum_invlaplace_weeks (c06lb).

### Output Parameters

1:     $\mathrm{finv}$ – double scalar
The approximation to the inverse Laplace transform at $t$.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

W  ${\mathbf{ifail}}=1$
The approximation to $f\left(t\right)$ is too large to be representable: finv is set to $0.0$.
W  ${\mathbf{ifail}}=2$
The approximation to $f\left(t\right)$ is too small to be representable: finv is set to $0.0$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

The error estimate returned by nag_sum_invlaplace_weeks (c06lb) in ${\mathbf{errvec}}\left(1\right)$ has been found in practice to be a highly reliable bound on the pseudo-error $\left|f\left(t\right)-\stackrel{~}{f}\left(t\right)\right|{e}^{-\sigma t}$.

nag_sum_invlaplace_weeks_eval (c06lc) is primarily designed to evaluate $\stackrel{~}{f}\left(t\right)$ when $t>0$. When $t\le 0$, the result approximates the analytic continuation of $f\left(t\right)$; the approximation becomes progressively poorer as $t$ becomes more negative.

## Example

See example for nag_sum_invlaplace_weeks (c06lb).
```function c06lc_example

fprintf('c06lc example results\n\n');

sigma0 = 3;
sigma = 0;
b = 0;
epstol = 1e-05;
[sigmaOut, bOut, m, acoef, errvec, ifail] = ...
c06lb(@f, sigma0, sigma, b, epstol, 'mmax', int64(512));

fprintf('\nNo. of coefficients returned by c06lb = %d\n\n', m);
fprintf('                   Computed           Exact       Pseudo\n');
fprintf('        t              f(t)            f(t)        error\n');
for j = 0:5
[finv, ifail] = c06lc(j, sigmaOut, bOut, acoef, errvec);
exact = sinh(3*j);
pserr = abs(finv-exact)/exp(sigmaOut*j);
fprintf(' %10.2f %15.4f %15.4f %12.1g\n',j, finv, exact, pserr);
end

function [f] = f(s)
% Evaluate the Laplace transform function.
f=3.0/(s^2-9.0);
if isreal(f)
f=complex(f);
end
```
```c06lc example results

No. of coefficients returned by c06lb = 64

Computed           Exact       Pseudo
t              f(t)            f(t)        error
0.00          0.0000          0.0000        2e-09
1.00         10.0179         10.0179        2e-09
2.00        201.7132        201.7132        1e-10
3.00       4051.5420       4051.5419        1e-09
4.00      81377.3949      81377.3957        3e-10
5.00    1634508.5023    1634508.6862        2e-09
```