original_docstring:  given points (xp, fp), fit a lagrange polynomial and return
          the value at point x 
docstring: given points (xp, fp), fit a lagrange polynomial and return
  the value at point x
docstring_tokens: given points ( xp fp ) fit a lagrange polynomial and return the value at point x
code: def lagrange_poly(x, xp, fp):
      """ given points (xp, fp), fit a lagrange polynomial and return
          the value at point x """
  
      f = 0.0
      
      # sum over points
      m = 0
      while (m < len(xp)):
  
          # create the Lagrange basis polynomial for point m        
          l = None
  
          n = 0
          while (n < len(xp)):
              if n == m:
                  n += 1
                  continue
  
              if l == None:
                  l = (x - xp[n])/(xp[m] - xp[n])
              else:
                  l *= (x - xp[n])/(xp[m] - xp[n])
  
              n += 1
  
          
          f += fp[m]*l
  
          m += 1
  
      return f
code_tokens: def lagrange_poly ( x , xp , fp ) : f = 0.0 m = 0 while ( m < len ( xp ) ) : l = None n = 0 while ( n < len ( xp ) ) : if n == m : n += 1 continue if l == None : l = ( x - xp [ n ] ) / ( xp [ m ] - xp [ n ] ) else : l *= ( x - xp [ n ] ) / ( xp [ m ] - xp [ n ] ) n += 1 f += fp [ m ] * l m += 1 return f
short_docstring: given points (xp, fp), fit a lagrange polynomial and return
  the value at point x
short_docstring_tokens: given points ( xp fp ) fit a lagrange polynomial and return the value at point x
comment: """ given points (xp, fp), fit a lagrange polynomial and return
          the value at point x """$SEP$# sum over points$SEP$# create the Lagrange basis polynomial for point m        