title: How to fix 'RuntimeWarning: divide by zero encountered in double_scalars'
body: <p>After doing <em>for loop</em> in my code, there is an error in one line:</p>
  
  <p><code>RuntimeWarning: divide by zero encountered in double_scalars</code></p>
  
  <p>and in another line two errors:</p>
  
  <p><code>RuntimeWarning: divide by zero encountered in double_scalars</code></p>
  
  <p><code>RuntimeWarning: invalid value encountered in arcsin</code></p>
  
  <p>I found it might be problem with float values, but im not sure about it and im typing it here for looking yours help. :)</p>
  
  <p>Here is the code:</p>
  
  <pre class="lang-py prettyprint-override"><code>T_max = 0.5 * v_PM(Me) * RTOD 
  DT = (90 - T_max) - np.fix(90 - T_max) 
  n = int(T_max * 2)
  
  P = np.zeros((n+1))    
  T = np.zeros((n+1))
  M = np.zeros((n+1))
  RR = np.zeros((n+1))
  LR = np.zeros((n+1))
  SL = np.zeros((n+1))
  
  for m in range(n+1):
      T[m] = (DT + m) * DTOR
      func = lambda x: T[m] - v_PM(x) 
      M[m] = brentq(func, 1, Me+1) 
      M[0] = 0
      P[m] = TR * np.tan(T[m]) #X-AXIS POINTS
      P[0] = 0
      RR[m] = -TR / P[m]
      RR[0] = 0
      LR[m] = (np.tan(T[m] + np.arcsin(1 / M[m]))) 
      LR[0] = 0
      SL[m] = -RR[m] 
      SL[0] = 0 
  </code></pre>
  
  <p>I defined earlier (before loop) <code>v_PM</code> and it's equal </p>
  
  <p><code>v_PM = lambda x : (A * np.arctan(np.sqrt(B * (x ** 2 - 1))) - np.arctan(np.sqrt(x ** 2 - 1)))</code></p>
  
  <p>As i mentioned, error 
  <code>RuntimeWarning: divide by zero encountered in double_scalars</code>
  refer to <code>RR[m] = -TR / P[m]</code></p>
  
  <p>and two errors 
  <code>RuntimeWarning: divide by zero encountered in double_scalars</code> 
  and</p>
  
  <p><code>RuntimeWarning: invalid value encountered in arcsin</code>  refers to:</p>
  
  <p><code>LR[m] = (np.tan(T[m] + np.arcsin(1 / M[m])))</code></p>
  
  <p>I put there also <code>P[0] = 0</code> and <code>M[0] = 0</code> etc. because i want to have first element as 0.</p>
  
  <p>I dont know if i can forget about this error and move on with my code or if it is some serious problem. Thanks for your help.</p>