View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Gaver-Stehfest algorithm for inverse Laplace transform

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

3.4 | 9 ratings Rate this file 21 Downloads (last 30 days) File Size: 1.57 KB File ID: #9987 Version: 1.0

Gaver-Stehfest algorithm for inverse Laplace transform


Wahyu Srigutomo (view profile)


15 Feb 2006 (Updated )

Gaver-Stehfest algorithm for inverse Laplace transform

| Watch this File

File Information

% ilt=gavsteh(funname,t,L)
% funname The name of the function to be transformed.
% t The transform argument (usually a snapshot of time).
% ilt The value of the inverse transform
% L number of coefficient ---> depends on computer word length used
% (examples: L=8, 10, 12, 14, 16, so on..)
% Numerical Inverse Laplace Transform using Gaver-Stehfest method
% 1. Villinger, H., 1985, Solving cylindrical geothermal problems using
% Gaver-Stehfest inverse Laplace transform, Geophysics, vol. 50 no. 10 p.
% 1581-1587
% 2. Stehfest, H., 1970, Algorithm 368: Numerical inversion of Laplace transform,
% Communication of the ACM, vol. 13 no. 1 p. 47-49
% Simple (and yet rush) examples included in functions fun1 and fun2 with
% their comparisons to the exact value (use testgs.m to run the examples)

MATLAB release MATLAB 6.0 (R12)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
04 Oct 2016 Vahid Salahi Ahmad Abadi

How Can I get this file? I not familiar how to download from file exchange

12 Apr 2011 Saskia

Saskia (view profile)

I am trying to solve the heat equation with both conduction and advective terms:

alpha*(d^2)T/(d^2)z-v*dT/dz-dT/dt (1)

where v=u*Cw/Cv, alpha is a constant. According to the literature the temperature frequency cariation solution of equation 1 is:

That=T0*exp(gamma*z)*exp(i*omega*t) (2)

where T0 and omega are constants. To get the actual temperature (T) value I am trying to use the Gaver-Stehfest numerical inversion. However, the values I get are not realistic, while my input parameters are fine. What am I doing wrong?

My input function is:

function f=fun_s(p)

%Define constants u=3.08*10^-8; %ms^-1 Cw=4.18*10^6; %Jm^-3K^-1 Cv=0.7*10^6; %Jm^-3K^-1 k=0.3; %Wm^-1K^-1 L=1; %m alpha=0.4*10^-6; %m^2 s^-1 omega=(2*pi())/(365.25*86400); theta0=11.5112; z=1;

v=u*Cw/Cv; gamma=(v-sqrt(v^2+4*i*omega*alpha))/(2*alpha);


which I then run with the following to get a daily temperature value:

t=1:2*pi/365:2*pi; l=length(t);

for i=1:l T(i)=gavsteh('fun_s',t(i),18); end

Any help on this will be greatly appreciated!

Comment only
28 May 2010 Peng

Peng (view profile)

this one totally helps a lot

Comment only
09 Jan 2010 Alireza Keramat

Thank you. It was interesting because of its simplicity.

26 Aug 2009 Mark

Mark (view profile)

Worked great for me. Nice job.

26 Feb 2009 Montaru Maxime

You need to use multi-precision toolbox to enhance results. Very good results for one staircase simulation with a big L. Beware when you simulate multiple staircase.

20 Oct 2008 Binbin Qi

I see something about this algorithm,but it is a different formula.Can you give me some data about this algorithm.Thank you! My E-mail is

Comment only
11 Mar 2008 GHADBANE Ahmed  
18 Sep 2007 Andor Bariska

This is a solid implementation of the Stehfest Laplace Inversion algorithm. It computes the Stehfest-vector for arbitrary even L. Two examples are supplied, the inversion of 1/s^2 and 1/(s^2+1).

14 Aug 2007 Heinrich Schuchardt

The main advantage of the algorithm is that it only uses real numbers. Hence it can easily be ported to other programming languages.

The algorithm is accurate for overdamped and slightly underdamped systems. But it is not accurate for systems with prolonged oscillations.

16 May 2006 Quentin de Waziers

useles function

25 Apr 2006 Sylvain Chupin

This function is not able to fit a simple cosinus!

01 Apr 2016 1.0

This is the version 1.0

Contact us