def l2_projection(f, basis, lim):
 r = 0
 for b in basis:
  r += (l2_inner_product(f, b, lim) * b)
 return r

def l2_projection ( f , basis , lim ) : r = 0 for b in basis : r += ( l2_inner_product ( f , b , lim ) * b ) return r
l2 projects the function f on the basis over the domain lim .