Вы находитесь на странице: 1из 10

Algorithm 796: A Fortran Software Package for the Numerical Inversion of the Laplace Transform Based on a Fourier Series

Method
LUISA DAMORE, GIULIANO LACCETTI, and ALMERICO MURLI Center for Research on Parallel Computing and Supercomputers (CPS-CNR) of the Italian National Research Council and University of Naples Federico II

A software package for the numerical inversion of a Laplace Transform function is described. Besides function values of F z for complex and real z , the user has only to provide the numerical value of the Laplace convergence abscissa 0 or, failing this, an upper bound to this quantity, and the accuracy he or she requires in the computed value of the inverse Transform. The method implemented is based on a Fourier series expansion of the inverse transform, and it is especially suitable when such inverse Laplace Transform is sectionally continuous. Categories and Subject Descriptors: D.3.2 [Programming Languages]: Language ClassificationsFORTRAN 77; G.1.9 [Numerical Analysis]: Integral Equations; G.1.2 [Numerical Analysis]: ApproximationNonlinear approximation General Terms: Algorithms Additional Key Words and Phrases: Automatic stopping criterion, Laplace Transform inversion, Fourier series methods

1. INTRODUCTION We describe a Fortran software package INVLTF for the numerical inversion of a Laplace Transform function. This package obtains approximations for the real-valued function f t , when numerical values of its Laplace Transform

Authors address: Center for Research on Parallel Computing and Supercomputers (CPS-CNR) of the Italian National Research Council and University of Naples Federico II, Via Cintia, Monte S. Angelo, Napoli, 80126, Italy; email: {damore; laccetti; murli}@matna2.dma.unina.it. Permission to make digital / hard copy of part or all of this work for personal or classroom use is granted without fee provided that the copies are not made or distributed for profit or commercial advantage, the copyright notice, the title of the publication, and its date appear, and notice is given that copying is by permission of the ACM, Inc. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and / or a fee. 2000 ACM 0098-3500/99/0900 0306 $5.00
ACM Transactions on Mathematical Software, Vol. 25, No. 3, September 1999, Pages 306 315.

Algorithm 796

307

Fz

eztftdt,

Rez 0,

are available for complex z , in a form of an user-supplied subprogram. The user must provide a single numerical value of t , the numerical value of the Laplace convergence abscissa 0 , or, failing this, an upper bound to this quantity. The user must also specify the accuracy he or she requires in the computed value of f t . The method implemented is based on a Fourier series expansion of f t , and it is especially suitable when the inverse Laplace Transform is sectionally continuous. The mathematical background and general information about the performance of the algorithm are described in this issue [DAmore et al. 1999]. 2. OUTLINE OF THE USE The present version of the software consists of a routine INVLTF written in double-precision Fortran 77 and two auxiliary routines QDACC and BACKCF which are, respectively, an implementation of the q-d algorithm and the corresponding computation of the continued fraction. The calling sequence is as follows:
CALL INVLTF (TOL,VALT,FZ,SIGMA0,SSBAR,NMAX,FZINV,ERR,IFZEVAL,WORK,IFAIL)

where
C C C C C C C C C C C C C C C C C C C C C C C INPUT PARAMETERS

TOL:

DOUBLE PRECISION.

ON ENTRY TOL CONTAINS THE RELATIVE REQUIRED ACCURACY. ON ENTRY, VALT CONTAINS A POSITIVE VALUE OF T FOR WHICH THE INVERSE LAPLACE TRANSFORM IS REQUIRED. VALT HAS TO BE GREATER THAN ZERO.

VALT:

DOUBLE PRECISION.

FZ:

COMPLEX*16 (DOUBLE PRECISION COMPLEX). NAME OF THE FUNCTION PROGRAMS FOR THE COMPLEX VALUED LAPLACE TRANSFORM TO BE INVERTED. ITS SPECIFICATION IS: COMPLEX*16 FUNCTION FZ(Z) COMPLEX*16 Z Z: COMPLEX*16. ON ENTRY, Z MUST SPECIFY THE POINT AT WHICH THE LAPLACE TRANSFORM FUNCTION VALUE IS REQUIRED.

ACM Transactions on Mathematical Software, Vol. 25, No. 3, September 1999.

308
C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C

L. DAmore et al.
FZ MUST BE DECLARED AS EXTERNAL IN THE PROGRAM FROM WHICH INVLTF IS CALLED.

SIGMA0: DOUBLE PRECISION.

ON ENTRY, SIGMA0 CONTAINS THE VALUE OF THE ABSCISSA OF CONVERGENCE OF THE LAPLACE TRANSFORM FUNCTION TO BE INVERTED OR AN UPPER BOUND TO THIS. IT IS RECOMMENDED THAT A CORRECT VALUE TO SIGMA0 OR A CORRECT UPPER BOUND TO SIGMA0 IS PROVIDED. IF AN INCORRECT VALUE IS USED THE ROUTINE APPEARS TO WORK WELL BUT CONVERGES TO COMPLETELY WRONG RESULTS. THERE IS NO WAY IN WHICH THE ROUTINE CAN DETECT THIS. ON ENTRY, IT SPECIFIES THE VALUE OF THE PARAMETER SS (GREATER THAN 2) TO BE USED IN CALCULATING THE PARAMETER D*T. TO OBTAIN DEFAULT OPTION (SS4.1d0) ONE MAY SET SSBAR 0. ON ENTRY, NMAX SPECIFIES THE MAXIMUM NUMBER OF EVALUATIONS OF FZ ALLOWED.

SSBAR:

DOUBLE PRECISION.

NMAX: INTEGER.

OUTPUT PARAMETERS FZINV: DOUBLE PRECISION.

ON EXIT, FZINV CONTAINS THE APPROXIMATION OF THE INVERSE LAPLACE TRANSFORM AT THE POINT VALT.

ERROR: DOUBLE PRECISION ARRAY OF DIMENSION 3. ON EXIT, ERROR(1) CONTAINS AN ESTIMATE OF THE RELATIVE ERROR WHICH SHOULD BE AN UPPER BOUND FOR ABS(TRUEVALUE AT VALT - FZINV) / ABS(TRUEVALUE AT VALT) ON EXIT, ERROR(2) CONTAINS AN ESTIMATE OF THE ABSOLUTE ERROR WHICH SHOULD BE AN UPPER BOUND FOR ABS(TRUEVALUE AT VALT - FZINV) ON EXIT, ERROR(3) CONTAINS AN ESTIMATE OF THE TRUNCATION ERROR MADE IN CALCULATING FZINV. IFZEVAL: INTEGER. ON EXIT, IFZEVAL CONTAINS THE NUMBER OF EVALUATIONS OF FZ USED TO OBTAIN FZINV. ON EXIT, A DIAGNOSTIC. 0 ALL INPUTS WITHIN LIMITS.

IFAIL: INTEGER.

ACM Transactions on Mathematical Software, Vol. 25, No. 3, September 1999.

Algorithm 796
C C C C C C C C C C C C

309

WORK : DOUBLE COMPLEX ARRAY OF

ALGORITHM APPARENTLY WORKED PROPERLY. 1 TOL IS EQUAL OR GREATER THAN 1. 2 VALT NOT POSITIVE -1 ACCURACY NOT REACHED AFTER NMAX FUNCTION EVALUATIONS. -2 ALGORITHM DID NOT APPEAR TO BE CONVERGING, POSSIBLY DUE TO AN UNSUITABLE VALUE OF THE PARAMETER SSBAR. DIMENSION(2,0:2*NMAX). WORKSPACE AREA.

The user is obliged to provide INVLTF with the numerical values for 0 and TOL , the required relative accuracy. Note, that, if TOL is less than the relative machine precision RELP , TOL is set to RELP . We would like to underline that it is particulary important that a correct value of 0 or a correct upper bound on 0 is provided by the user. If an incorrect value is used and if this results in a countour in which 0 , this routine appears to work well but converges to a completely incorrect function. This includes a residue of a function related to F z at poles lying between and 0 . There is no way in which the routines can detect this. A sample calling program to invert the function

Fz

1 z z1
2

is listed in Section 3. The exact inverse is

ft

e t/ 2

sin t 3 2

3. EXAMPLE PROGRAM
C C C C C C C C C C C C C C C C C *********************************************************** EXAMPLE PROGRAM TO USE THE ROUTINE INVLTF FOR THE INVERSION OF A LAPLACE TRANSFORM FUNCTION. THIS VERSION USES BOTH REAL AND COMPLEX DOUBLE PRECISION OPERATIONS.

THE TEST EXAMPLE IS: F(Z)1/(Z*ZZ1) WITH ITS INVERSE: F(T) 2/SQRT(3) * EXP(-T/2)* SIN(T*SQRT(3)/2) FOR THIS FUNCTION SIGMA0 -0.5 AND WE USE THE DEFAULT OPTION
ACM Transactions on Mathematical Software, Vol. 25, No. 3, September 1999.

310
C C C C C C C C C C

L. DAmore et al.

SSBAR 0.0D0 THE INVERSE TRANSFORM IS COMPUTED AT 23 POINTS T 1,20 STEP1, T30,50 STEP10 THESE VALUES ARE STORED IN THE ARRAY TARRAY

C C

C C

C C

PROGRAM MAIN .. Parameters.. INTEGER NMAX PARAMETER (NMAX550) .. .. Local Scalars.. DOUBLE PRECISION EXF,SIGMA0,TOL,SSBAR INTEGER I,NT CHARACTER*100 AA LOGICAL STOP .. .. Local Arrays.. DOUBLE COMPLEX WORK(2,0:2*NMAX) DOUBLE PRECISION DIFABS(50),DIFREL(50), FZINV(50),TARRAY(50), ERROR(3,50),ERR(3) INTEGER IFAIL(50),IFZEVAL(50) .. .. External Functions.. DOUBLE COMPLEX FZ

C C C C C C C C C C

DOUBLE PRECISION FEX EXTERNAL FZ,FEX .. .. External Subroutines.. EXTERNAL INVLTF .. .. Intrinsic Functions.. INTRINSIC ABS .. ***************************************************************** SET UP THE OUTPUT ***************************************************************** AA ***************************************************************** ************* WRITE (*,FMT9000) AA,AA WRITE (*,FMT9090)AA WRITE (*,FMT9080) **************************************************************** NOW, SET INPUT PARAMETERS FOR INVLTF ****************************************************************

C C C C C

ACM Transactions on Mathematical Software, Vol. 25, No. 3, September 1999.

Algorithm 796
C C SIGMA0-.5D0 WRITE (*,FMT9110) SIGMA0 NT23 DO 111 I1,20 TARRAY(I)1.D0(I-1)*1.D0 CONTINUE TARRAY(21)30. DO 112 I22,23 TARRAY(I)30.D010.D0*(I-21) CONTINUE TOL.1D-6 WRITE (*,FMT9020) TOL SSBAR0.0D0 THIS GIVES DEFAUT OPTION SS 4.1 ************************************************************ CALL OF THE ROUTINE INVLTF ************************************************************

311

111

112

C C C C C C C C

2 C C

DO 2 I1,NT CALL INVLTF(TOL,TARRAY(I),FZ,SIGMA0,SSBAR,NMAX,FZINV(I),ERR, IFZEVAL(I),WORK,IFAIL(I)) IF(IFAIL(I).NE. -2) THEN ERROR(1,I) ERR(1) ERROR(2,I) ERR(2) ERROR(3,I) ERR(3) ENDIF CONTINUE

WRITE (*,FMT9040) AA,AA DO 30 I 1,NT STOP.FALSE. IF (IFAIL(I).EQ.-2 )THEN WRITE (*,FMT9100) I,IFAIL(I) STOP.TRUE. ENDIF IF (.NOT. STOP) THEN C EXF FEX(TARRAY(I)) DIFABS(I) ABS(EXF-FZINV(I)) IF (EXF.NE.0.D0) THEN DIFREL(I) DIFABS(I)/ABS(EXF) ELSE DIFREL(I) DIFABS(I) END IF EXF FEX(TARRAY(I)) IF (IFAIL(I).NE.-2) THEN
ACM Transactions on Mathematical Software, Vol. 25, No. 3, September 1999.

312

L. DAmore et al.
WRITE (*,FMT9070) TARRAY(I),FZINV(I),EXF,ERROR(1,I), DIFREL(I),ERROR(3,I),ERROR(2,I),DIFABS(I),IFZEVAL(I), IFAIL(I) ELSE WRITE (*,FMT9060) TARRAY(I),IFAIL(I) END IF

END IF 30 CONTINUE WRITE (*,FMT9030)

STOP C C 9000 FORMAT (1X,A78,/,/,15X, EXAMPLE PROGRAM TO USE THE ROUTINE INVLTF,/,10X, FOR THE INVERSION OF A LAPLACE TRANSFORM FUNCTION.,/,/,10X, THIS VERSION USES BOTH REAL AND COMPLEX DOUBLE PRECISION,/,10X, OPERATIONS.,/,/,10X, AUTHORS: LUISA D AMORE, GIULIANO LACCETTI, ALMERICO MURLI,/,/, 1X,A78,/) 9020 FORMAT(/,1X,TOL -- ,E15.7) 9030 FORMAT(/,1X,T: POINT AT WHICH THE INVERSE TRANSFORM IS, COMPUTED;,/,/,1X, FEX : EXACT VALUE OF THE INVERSE TRANSFORM;,/,/,1X, FCAL : COMPUTED VALUE OF THE INVERSE TRANSFORM;,/,/,1X, ESTREL : ESTIMATED RELATIVE ERROR;,/,/,1X, RELERR : ACTUAL RELATIVE ERROR;,/,/,1X, TRUNERR: TRUNCATION ERROR;,/,/,1X, ESTABS : ESTIMATED ABSOLUTE ERROR;,/,/,1X, ABSERR : ACTUAL ABSOLUTE ERROR;,/,/,1X, N : # OF FUNCTION EVALUATIONS;,/,/,1X, IFAIL : 0 NO INPUT ERRORS; SUCCESSFUL RUN (ACCURACY REACHED and IFZEVALNMAX;/,10X, 1 TOL 1;,/,10X, 2 T-VALUE LESS THAN ZERO;,/,10X, -1 ACCURACY NOT REACHED and IFZEVAL NMAX;,/,10X, -2 THE CHOICE FOR SSBAR MAY BE NOT OPTIMAL;,/,10X, IN SUCH A CASE THE USER MAY SLIGHTLY,/,10X, CHANGE THE DEFAULT VALUE.,/) 9040 FORMAT (/,A78,/, T,6X,FCAL,8X,FEX,4X, ESTREL,2X, RELERR,2X,TRUNERR,2X,ESTABS,2X,ABSERR,2X,N,2X, IFAIL,/,A78,/,/) 9060 FORMAT (F5.1,80X,I2) 9070 FORMAT (F4.0,1X,E11.5,1X,E11.5,1X,E7.2,1X,E7.2,1X,E7.2,1X,E7.2,1X, E7.2,1X,I3,2X,I2) 9080 FORMAT (/,1X, THE T-VALUES AT WHICH THE INVERSE IS REQUIRED ARE,/ 1X, T1,20 STEP1 AND T30,50 STEP10.,/ FOR EACH RUN, THE INPUT PARAMETER TVAL IS DIFFERENT / 1X, THE OTHER INPUT PARAMETERS ARE THE SAME IN EACH RUN,/ 1X, NAMELY TOL 10E-7 SIGMA0 -0.5 SSBAR 0.0 NMAX 550,/) 9090 FORMAT(//,2X, THE EXAMPLE TEST IS/ F(Z)1/(Z*ZZ1) // WITH ITS INVERSE /
ACM Transactions on Mathematical Software, Vol. 25, No. 3, September 1999.

Algorithm 796
F(T) 2/SQRT(3) * EXP(-T/2)* SIN(T*SQRT(3)/2)/// //,1X,A78) 9100 FORMAT (/,1X,ERROR DETECTED, I , I3, IFAIL,I3) 9110 FORMAT (/, ABSCISSA OF CONVERGENCE --- ,F5.1,/) END C FUNCTION FZ CALLED BY THE INVERSION SOFTWARE ** C ** C *********************************************** COMPLEX*16 FUNCTION FZ(Z) C .. C .. Scalar Arguments.. DOUBLE COMPLEX Z C .. C FZ (1.D0,0.D0)/ (Z*ZZ (1.D0,0.D0)) C RETURN END

313

C ********************************************************************* C C C FZs COMPANION FUNCTION FEX TO COMPUTE THE EXACT VALUE OF THE C INVERSE TRANSFORM C C C ********************************************************************* DOUBLE PRECISION FUNCTION FEX(X) C C C C .. Scalar Arguments.. DOUBLE PRECISION X C .. C .. Intrinsic Functions.. INTRINSIC DEXP,DSIN,DSQRT C .. C ******************************************************************** C FEX 2.D0/DSQRT(3.D0)*DEXP(-X/2.D0)*DSIN(X*DSQRT(3.D0)/2.D0) C C RETURN END C C C C C ********************************************************************* C C ********* END OF EXAMPLE PROGRAM ********************************

ACM Transactions on Mathematical Software, Vol. 25, No. 3, September 1999.

314

L. DAmore et al.

Running this program on an IBM RISC 6000 workstation the following output is obtained:
****************************************************************************** EXAMPLE PROGRAM TO USE THE ROUTINE INVLTF FOR THE INVERSION OF A LAPLACE TRANSFORM FUNCTION. THIS VERSION USES BOTH REAL AND COMPLEX DOUBLE PRECISION OPERATIONS. AUTHORS: LUISA D AMORE, GIULIANO LACCETTI, ALMERICO MURLI ****************************************************************************** THE EXAMPLE TEST IS F(Z)1/(Z*ZZ1) WITH ITS INVERSE F(T) 2/SQRT(3) * EXP(-T/2)* SIN(T*SQRT(3)/2) ****************************************************************************** THE T-VALUES AT WHICH THE INVERSE IS REQUIRED ARE T1,20 STEP1 AND T30,50 STEP10. FOR EACH RUN, THE INPUT PARAMETER TVAL IS DIFFERENT THE OTHER INPUT PARAMETERS ARE THE SAME IN EACH RUN NAMELY TOL 10E-7 SIGMA0 -0.5 SSBAR 0.0 NMAX 550 ABSCISSA OF CONVERGENCE --- -.5 TOL --.1000000E-06 ****************************************************************************** T FCAL FEX ESTREL RELERR TRUNERR ESTABS ABSERR N IFAIL ****************************************************************************** 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 30. 40. 50. .53351E00 .53351E00 .41928E00 .41928E00 .13324E00 .13324E00 -.49530E-01 -.49530E-01 -.87942E-01 -.87942E-01 -.50892E-01 -.50892E-01 -.76437E-02 -.76437E-02 .12715E-01 .12715E-01 .12805E-01 .12805E-01 .53855E-02 .53855E-02 -.47816E-03 -.47816E-03 -.23570E-02 -.23570E-02 -.16764E-02 -.16764E-02 -.45041E-03 -.45041E-03 .26275E-03 .26275E-03 .37219E-03 .37219E-03 .19584E-03 .19584E-03 .16989E-04 .16989E-04 -.58695E-04 -.58695E-04 -.52378E-04 -.52378E-04 .26491E-06 .26491E-06 -.19849E-09 -.19849E-09 -.10096E-10 -.10096E-10 .13E-07 .19E-07 .15E-07 .17E-07 .15E-07 .23E-07 .22E-07 .10E-07 .12E-07 .12E-07 .11E-07 .15E-07 .15E-07 .20E-07 .26E-07 .17E-07 .16E-07 .12E-07 .25E-07 .12E-07 .11E-07 .10E-07 .41E-06 .37E-10 .45E-09 .43E-09 .13E-10 .74E-09 .12E-08 .45E-09 .30E-11 .42E-10 .19E-09 .73E-09 .39E-09 .36E-09 .50E-10 .94E-10 .16E-09 .61E-09 .34E-09 .11E-08 .27E-08 .18E-09 .15E-06 .15E-05 .28E-08 .11E-07 .85E-08 .21E-07 .53E-08 .91E-08 .74E-08 .64E-08 .48E-08 .16E-07 .13E-07 .23E-07 .12E-07 .56E-08 .46E-09 .73E-08 .16E-08 .13E-07 .22E-08 .97E-08 .14E-08 .13E-08 .46E-08 .14E-07 .48E-08 .17E-07 .96E-08 .97E-08 .16E-07 .12E-07 .70E-08 .19E-07 .55E-08 .15E-07 .24E-08 .17E-08 .15E-07 .20E-07 .18E-08 .14E-07 .13E-08 .98E-08 .00E00 .96E-09 .40E-06 .30E-06 .20E-10 .19E-09 .58E-10 .63E-12 .65E-10 .60E-10 .35E-11 .38E-13 .54E-12 .10E-11 .35E-12 .92E-12 .61E-12 .23E-13 .25E-13 .58E-13 .12E-12 .59E-14 .66E-13 .14E-12 .47E-16 .30E-16 .15E-16 27 25 29 29 31 29 33 33 35 35 39 35 37 39 37 41 41 45 43 43 57 73 75 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

ACM Transactions on Mathematical Software, Vol. 25, No. 3, September 1999.

Algorithm 796
T : FEX : FCAL : ESTREL : RELERR : TRUNERR: ESTABS : ABSERR : N : IFAIL :

315

POINT AT WHICH THE INVERSE TRANSFORM IS COMPUTED; EXACT VALUE OF THE INVERSE TRANSFORM; COMPUTED VALUE OF THE INVERSE TRANSFORM; ESTIMATED RELATIVE ERROR; ACTUAL RELATIVE ERROR; TRUNCATION ERROR; ESTIMATED ABSOLUTE ERROR; ACTUAL ABSOLUTE ERROR; # OF FUNCTION EVALUATIONS; 0 NO INPUT ERRORS; SUCCESSFUL RUN (ACCURACY REACHED and IFZEVALNMAX); 1 TOL 1; 2 T-VALUE LESS THAN ZERO; -1 ACCURACY NOT REACHED and IFZEVAL NMAX; -2 THE CHOICE FOR SSBAR MAY BE NOT OPTIMAL; IN SUCH A CASE THE USER MAY SLIGHTLY CHANGE THE DEFAULT VALUE.

4. PORTABILITY The package INVLTF is written in Fortran 77 and uses the double-precision complex arithmetic. It runs successfully on different platforms allowing such feature. Only one machine-dependent constant must be specified; this defines the machine accuracy: such a constant is supplied by the function D1MACH in which the user has to choose the appropriate environment.
ACKNOWLEDGMENTS

We thank James Lyness for his many helpful suggestions in the preparation of this article.
REFERENCES DAMORE, L., LACCETTI, G., AND MURLI, A. 1999. An implementation of a Fourier series method for the numerical inversion of the Laplace Transform. ACM Trans. Math. Softw. 25, 3 (Sept.). Received: October 1995; 1999 revised: November 1996 and October 1997; accepted: February

ACM Transactions on Mathematical Software, Vol. 25, No. 3, September 1999.