name: legendre_coefficients input: d:degree output: c: coefficients of p(d,x) cm1 = 0 c = 0 LOOP from i = 0 to d cm2 = cm1 cm1 = c c = array of zeros of length i+1 if i is 0 c = 1 else c(1:i-1) = ( -i+1) * cm2 / i c(2:i+1) = (2*i-1) * cm1 / i