C06LAF estimates values of the inverse Laplace transform of a given function using a Fourier series approximation. Real and imaginary parts of the function, and a bound on the exponential order of the inverse, are required.
Given a function defined for complex values of , C06LAF estimates values of its inverse Laplace transform by Crump's method (see Crump (1976)). (For a definition of the Laplace transform and its inverse, see the C06 Chapter Introduction.)
Crump's method applies the epsilon algorithm (see Wynn (1956)) to the summation in Durbin's Fourier series approximation (see Durbin (1974))
for , by choosing such that a prescribed relative error should be achieved. The method is modified slightly if so that an estimate of can be obtained when it has a finite value. is calculated as , where . You specify and , an upper bound on the exponential order of the inverse function . has two alternative interpretations:
is the smallest number such that
for large ,
is the real part of the singularity of with largest real part.
The method depends critically on the value of . See Section 8 for further details. The routine calculates at least two different values of the parameter , such that , in an attempt to achieve the requested relative error and provide error estimates. The values of
, for , must be supplied in monotonically increasing order. The routine calculates the values of the inverse function in decreasing order of .
Crump K S (1976) Numerical inversion of Laplace transforms using a Fourier series approximation J. Assoc. Comput. Mach.23 89–96
Durbin F (1974) Numerical inversion of Laplace transforms: An efficient improvement to Dubner and Abate's method Comput. J.17 371–376
Wynn P (1956) On a device for computing the transformation Math. Tables Aids Comput.10 91–96
1: FUN – SUBROUTINE, supplied by the user.External Procedure
FUN must evaluate the real and imaginary parts of the function for a given value of .
On exit: an estimate of the error in . This is usually an estimate of relative error but, if , estimates the absolute error. is unreliable when is small but slightly greater than RELERR.
6: RELERR – REAL (KIND=nag_wp)Input
On entry: the required relative error in the values of the inverse Laplace transform. If the absolute value of the inverse is less than RELERR, then absolute accuracy is used instead. RELERR must be in the range . If RELERR is set too small or to , then the routine uses a value sufficiently larger than machine precision.
7: ALPHAB – REAL (KIND=nag_wp)Input
On entry: , an upper bound for (see Section 3). Usually, should be specified equal to, or slightly larger than, the value of . If then the prescribed accuracy may not be achieved or completely incorrect results may be obtained. If is too large C06LAF will be inefficient and convergence may not be achieved.
Note: it is as important to specify correctly as it is to specify the correct function for inversion.
8: TFAC – REAL (KIND=nag_wp)Input
On entry: , a factor to be used in calculating the parameter . Larger values (e.g., ) may be specified for difficult problems, but these may require very large values of MXTERM.
9: MXTERM – INTEGERInput
On entry: the maximum number of (complex) terms to be used in the evaluation of the Fourier series.
, except for very simple problems.
10: NTERMS – INTEGEROutput
On exit: the number of (complex) terms actually used.
11: NA – INTEGEROutput
On exit: the number of values of used by the routine. See Section 8.
12: ALOW – REAL (KIND=nag_wp)Output
On exit: the smallest value of used in the algorithm. This may be used for checking the value of see Section 8.
13: AHIGH – REAL (KIND=nag_wp)Output
On exit: the largest value of used in the algorithm. This may be used for checking the value of see Section 8.
14: NFEVAL – INTEGEROutput
On exit: the number of calls to FUN made by the routine.
15: WORK() – REAL (KIND=nag_wp) arrayWorkspace
16: IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to , . If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value is recommended. If the output of error messages is undesirable, then the value is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if on exit, the recommended value is . When the value is used it is essential to test the value of IFAIL on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6 Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by X04AAF).
Note: C06LAF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
are not in strictly increasing order.
is too large for this value of ALPHAB. If necessary, scale the problem as described in Section 8.
The required accuracy cannot be obtained. It is possible that ALPHAB is less than . Alternatively, the problem may be especially difficult. Try increasing TFAC, ALPHAB or both.
Convergence failure in the epsilon algorithm. Some values of may be calculated to the desired accuracy; this may be determined by examining the values of . Try reducing the range of T or increasing MXTERM. If still results, try reducing TFAC.
All values of have been calculated but not all are to the requested accuracy; the values of should be examined carefully. Try reducing the range of , or increasing TFAC, ALPHAB or both.
The error estimates are often very close to the true error but, because the error control depends on an asymptotic formula, the required error may not always be met. There are two principal causes of this: Gibbs' phenomena, and zero or small values of the inverse Laplace transform.
Gibbs' phenomena (see the C06 Chapter Introduction) are exhibited near (due to the method) and around discontinuities in the inverse Laplace transform . If there is a discontinuity at then the method converges such that .
Apparent loss of accuracy, when is small, may not be serious. Crump's method keeps control of relative error so that good approximations to small function values may appear to be very inaccurate. If is estimated to be less than RELERR then this routine switches to absolute error estimation. However, when is slightly larger than RELERR the relative error estimates are likely to cause . If this is found inconvenient it can sometimes be avoided by adding to the function , which shifts the inverse to .
Loss of accuracy may also occur for highly oscillatory functions.
More serious loss of accuracy can occur if is unknown and is incorrectly estimated. See Section 8.
8 Further Comments
The value of is less important in general than the value of NTERMS. Unless FUN is very inexpensive to compute, the timing is proportional to . For simple problems but in difficult problems NA may be somewhat larger.
You are referred to the C06 Chapter Introduction for advice on simplifying problems with particular difficulties, e.g., where the inverse is known to be a step function.
The method does not work well for large values of when is positive. It is advisable, especially if is obtained, to scale the problem if is much greater than . See the C06 Chapter Introduction.
The range of values of specified for a particular call should not be greater than about units. This is because the method uses parameters based on the value and these tend to be less appropriate as becomes smaller. However, as the timing of the routine is not especially dependent on , it is usually far more efficient to evaluate the inverse for ranges of than to make separate calls to the routine for each value of .
The most important parameter to specify correctly is ALPHAB, an upper bound for . If, on entry, ALPHAB is sufficiently smaller than then completely incorrect results will be obtained with . Unless is known theoretically it is strongly advised that you should test any estimated value used. This may be done by specifying a single value of (i.e , ) with two sets of suitable values of TFAC, RELERR and MXTERM, and examining the resulting values of ALOW and AHIGH. The value of should be chosen very carefully and the following points should be borne in mind:
should be small but not too close to because of Gibbs' phenomenon (see Section 7),
the larger the value of , the smaller the range of values of that will be used in the algorithm,
should ideally not be chosen such that or a very small value. For suitable problems might be chosen as, say, or depending on these factors. The routine calculates ALOW from the formula
Additional values of are computed by adding to the previous value. As , it will be seen that large values of TFAC and RELERR will test for close to ALPHAB. Small values of TFAC and RELERR will test for large. If the result of both tests is , with comparable values for the inverse, then this gives some credibility to the chosen value of ALPHAB. You should note that this test could be more computationally expensive than the calculation of the inverse itself. The example program (see Section 9) illustrates how such a test may be performed.
This example estimates the inverse Laplace transform of the function . The true inverse of is . Two preliminary calls to the routine are made to verify that the chosen value of ALPHAB is suitable. For these tests the single value is used. To test values of close to ALPHAB, the values and are chosen. To test larger , the values and are used. Because the values of the computed inverse are similar and in each case, these tests show that there is unlikely to be a singularity of in the region .