stehfest(func, time, bound=12, arg_dict=None, **kwargs)[source]

The stehfest-algorithm for numerical laplace inversion.

The Inversion was derivide in ‘’Stehfest 1970’’[R1] and is given by the formula

\[\begin{split}f\left(t\right) &=\frac{\ln2}{t}\sum_{n=1}^{N}c_{n}\cdot\tilde{f} \left(n\cdot\frac{\ln2}{t}\right)\\ c_{n} &=\left(-1\right)^{n+\frac{N}{2}}\cdot \sum_{k=\left\lfloor \frac{n+1}{2}\right\rfloor } ^{\min\left\{ n,\frac{N}{2}\right\} } \frac{k^{\frac{N}{2}+1}\cdot\binom{2k}{k}} {\left(\frac{N}{2}-k\right)!\cdot\left(n-k\right)! \cdot\left(2k-n\right)!}\end{split}\]

In the algorithm \(N\) corresponds to bound, \(\tilde{f}\) to func and \(t\) to time.

  • func (callable) – function in laplace-space that shall be inverted. The first argument needs to be the laplace-variable: func(s, **kwargs)

    func should be capable of taking numpy arrays as input for s and the first shape component of the output of func should match the shape of s.

  • time (float or numpy.ndarray) – time-points to evaluate the function at

  • bound (int, optional) – Here you can specify the number of interations within this algorithm. Default: 12

  • arg_dict (dict or None, optional) – Keyword-arguments given as a dictionary that are forwarded to the function given in func. Will be merged with **kwargs This is designed for overlapping keywords in stehfest and func.Default: None

  • **kwargs – Keyword-arguments that are forwarded to the function given in func. Will be merged with arg_dict


Array with all evaluations in Time-space.

Return type





Stehfest, H., ‘’Algorithm 368: Numerical inversion of laplace transforms [d5].’’ Communications of the ACM, 13(1):47-49, 1970


The parameter time needs to be strictly positiv.

The algorithm gets unstable for bound values above 20.


>>> f = lambda x: x**-1
>>> stehfest(f, [1,10,100])
array([ 1.,  1.,  1.])