title: Error dividing by zero
body: <p>Hi I am trying to calculate the implied vol but because my variable T is under 0.1 I am getting this strange error. "divide by zero encountered in double_scalars"
  I would like to know what I am doing wrong.  Thanks.</p>
  
  <pre><code>#Importamos librerias
  from math import log,exp,sqrt
  from scipy import stats
  #Definimos nuestra funcion acumulativa 
  N = stats.norm.cdf
  
  #Definimos la formula de Black Scholes para una opción Call
  def BS(S0,K,T,r,sigma):
      S0 = float(S0)
      d1 = (log(S0/K)+(r + 0.5 * sigma**2)*T)/(sigma*sqrt(T))
      d2 = (log(S0/K)+(r - 0.5*sigma**2)*T)/(sigma*sqrt(T))
      value = (S0*N(d1)-K*exp(-r*T)*N(d2))
      return value
  
  
  #Definimos Vega que es la derivada con respecto de sigma
  def Vega(S0,K,T,r,sigma):
      S0 = float(S0)
      d1 = (log(S0/K)+(r + 0.5 * sigma**2)*T)/(sigma*sqrt(T))
      vega = S0 * N(d1)*sqrt(T)
      return vega
  
  #Definimos la volatilidad implicita usando BS y Vega, usamos el metodo de 
  #Newton para resolver
  def ImpliedVol(S0, K, T, r, C0, sigma_est, it=100):
      for i in range(it):
          sigma_est -= ((BS(S0,K,T,r, sigma_est)-C0)/Vega(S0,K,T,r,sigma_est))
      return sigma_est
  
  #Calculamos de Acuerdo a los parametros
  
  S0 = 173
  K = 130
  T = 0.02
  r = 0.029
  C0 = 42
  Sigma_init = 0.5
  
  print(ImpliedVol(S0,K,T,r,C0,Sigma_init))
  </code></pre>