title: Laplace inverse in Python with mpmath
body: <p>I want to use "DE HOOG" algorithm for numerical Laplace inverse transform. I want to use the "mpmath" package and I installed it from the link:</p>
  
  <p><a href="https://github.com/klkuhlm/mpmath" rel="nofollow noreferrer">https://github.com/klkuhlm/mpmath</a></p>
  
  <p>Lets say I need to find the inverse Laplace transform of the below function at t=1:</p>
  
  <p>f = 1/(s-1)</p>
  
  <p>The inverse Laplace transform of f is : e^(t)</p>
  
  <p>At t=1 the result is expected to be =  e</p>
  
  <pre><code>import mpmath as mp
  import numpy as np
  
  def f(s):
      return 1 / (s-1)
  
  t = np.linspace(0.01,0.5,10)
  
  G = []
  
  for i in range(0,4):
      G.append(mp.invlapdehoog(f, t[i]))
  
  print G 
  </code></pre>
  
  <p>The thing is it works perfectly only when I set the range of the "i" less than 4. For example once I substitute:</p>
  
  <pre><code>for i in range(0,5): #or for i in range(0,more than 5):
  </code></pre>
  
  <p>I get this error:</p>
  
  <p><a href="https://i.stack.imgur.com/z5eKa.png" rel="nofollow noreferrer">enter image description here</a>       </p>
  
  <p>Could you please help me fix this problem?</p>
  
  <p>Thanks!</p>