MATLAB: How does matlab compute legendreP(n,x)

interpolation

A bad way to compute P_n(x) for large n, with P_n the nth Legendre polynomial, is to compute all the coefficients of P_n and build up the polynomial. My question is, how does matlab's legendreP(n,x) function get round this? What is the algorithm it is using?

Best Answer

At the MATLAB level, command
mupad
When that window comes up, type into it
expose(orthpoly::legendre)
and you will be shown the source code for legendreP
I think it might be using the recurrence method mentioned on the legendreP page.