title: Python: fsolve near asymptotic region
body: <p>For <code>E=0.46732451</code> and <code>t=1.07589765</code> I am trying to solve for the upper limit of the integral t= \int_{0}^{z} 1/sqrt(2*(0.46732451-z**2)), I plotted this function and it looks like this <a href="https://i.stack.imgur.com/sSzkv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sSzkv.png" alt="z vs t"></a>.</p>
  
  <p>Around <code>t=1</code> it kind of asymptotes. </p>
  
  <p>I have the following code </p>
  
  <pre><code>import numpy as np
  from scipy import integrate
  from scipy.optimize import fsolve
  
  def fg(z_up,t,E):
        def h(z,E):
             return 1/(np.sqrt(2*(E-z**2)))
  
        b, err = integrate.quad(h, 0, z_up,args=(E)) 
        return b-t 
  
  
  
  x0 = 0.1
  print fsolve(fg, x0, args=(1.07589765, 0.46732451))[0]
  </code></pre>
  
  <p>But this code just outputs the guess value, no matter what I put, so I am guessing it has something to do with the fact that the curve asymptotes there. I should note that this code works for other values of <code>t</code> which are away from the asymptotic region.  </p>
  
  <p>Can anyone help me resolve this? </p>
  
  <p>Thanks </p>
  
  <p><strong>EDIT</strong> After playing around for a while, I solved the problem, but it's kind of a patchwork, it only works for similar problems not in general (or does it?) </p>
  
  <p>I made the following changes: the maximum value that <code>z</code> can attain is <code>sqrt(0.46732451)</code>, so I set <code>x0=0.5*np.sqrt(0.46732451)</code> and set <code>factor</code> anywhere between <code>0.1</code> to <code>1</code>, and out pops the correct answer. I don't have an explanation for this, perhaps someone who is an expert in this matter can help?    </p>