#NEWLINE# def l2_gram_schmidt( list , lim ) : #NEWLINE# #INDENT# '\n    Orthonormalizes the "list" of functions using the Gram-Schmidt process.\n\n    Examples\n    ========\n\n    >>> from sympy import Symbol\n    >>> from gibbs_phenomenon import l2_gram_schmidt\n\n    >>> x = Symbol(\'x\', real=True)    # perform computations over reals to save time\n    >>> l2_gram_schmidt([1, x, x**2], (x, -1, 1))\n    [sqrt(2)/2, sqrt(6)*x/2, 3*sqrt(10)*(x**2 - 1/3)/4]\n\n    ' #NEWLINE# r = [ ] #NEWLINE# for a in list : #NEWLINE# #INDENT# if ( r == [ ] ) : #NEWLINE# #INDENT# v = a #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# v = ( a - l2_projection ( a , r , lim ) ) #NEWLINE# #UNINDENT# v_norm = l2_norm ( v , lim ) #NEWLINE# if ( v_norm == 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'The sequence is not linearly independent.' ) #NEWLINE# #UNINDENT# r . append ( ( v / v_norm ) ) #NEWLINE# #UNINDENT# return r