title: Complex function curve fitting (Python)
body: <p>I'm currently trying to fit data to this function to exctract &quot;e/lambda&quot; :
  <a href="https://i.stack.imgur.com/r7aSk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r7aSk.png" alt="Formula" /></a></p>
  <p>To do so, I tried (for the first time) to fit the data using python and I rearranged a little the fit function :</p>
  <pre><code>import matplotlib.pyplot as plt
  import scipy.optimize as optimize
  import numpy as np
  
  # data
  
  Io = np.array([0.3,0.5,1.4,2.9,3.8])
  Is = np.array([2.7,2.7,2.7,2.7,2.7])
  R = Io/Is
  
  T = np.array([0.,50,70,80,85])
  F = R/R[0]
  
  plt.plot(T, F, 'ro', label=&quot;original data&quot;)
  
  # curvefit
  ## a = np.exp(e/lambda)
  
  def func(T, a):
      return a * (((np.exp ((np.cos(T)-1)/(np.cos(T)))) - \
                   (np.exp ((1-np.cos(T))/((np.cos(T))**2)))) \
                  / ((np.exp ((np.cos(T)-1)/(np.cos(T)))) - \
                     (np.exp ((1-np.cos(T))/((np.cos(T)))))))
  
  popt, pcov = optimize.curve_fit(func, T, F, maxfev=100000)
  
  t = np.linspace(0,85)
  plt.plot(t, func(t, *popt), label=&quot;Fitted Curve&quot;)
  
  plt.legend(loc='upper left')
  plt.show()
  </code></pre>
  <p>However, I'm getting this message : &quot;Optimal parameters not found: Number of calls to function has reached maxfev = 100000&quot;</p>
  <p>This might be more a mathematical issue since I've tried succesfully this code with another function :</p>
  <pre><code>def func(T, a, b, c):
      return a + np.exp(b*T-c)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/y1l7W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y1l7W.png" alt="Fit obtained" /></a></p>
  <p>Does anyone know if it is possible to fit this function using it's &quot;true&quot; form ?</p>
  <p>Thanks !!</p>