Programming Guide / legendre



actually, a faster, non-recursive version I came up with is just this...
 

lp(q,x):= block([p0:rat(1),p1:x,pn],
   x:rat(x),
   for n:2 thru q do
  (pn: 1/n*(x*(2*n-1)*p1-(n-1)*p0),
   p0:p1,
   p1:pn),
pn)$
 
lp(200,x)  took  0.25 seconds
vs
LegendreNN(200,x)   which took 3.656 seconds
So there is a speedup of 14.6
 
Using mapping and lists to simulate polynomial multiplication (by an integer
multiple of x) and polynomial addition is less efficient.
 
RJF