MATLAB Is There a MATLAB Routine for Simple Legendre Polynomials of a Specific Degree?

AI Thread Summary
In MATLAB, the function legendre(n, X) generates Legendre polynomials, but it returns a large array that can be inefficient to call repeatedly, especially when iterating in double for loops for high values of N, such as 2000. The discussion seeks a more efficient method to obtain just the simple Legendre polynomial of degree n and order m=0, rather than the entire array. A potential solution is referenced from the Numerical Recipes book, specifically the third edition, which includes routines for Bessel functions that may assist in this context. Caution is advised as these routines may contain hard-to-find bugs.
Somefantastik
Messages
226
Reaction score
0
I see in MATLAB that you can call legendre(n,X) and it returns the associated legendre polynomials. All I need is is the simple Legendre polynomial of degrees 0-299, which corresponds to the first element in the array that this function returns. I don't want to call this function and get this [rather large] array back every time, because I am iterating inside a double for loop. This is not so much a problem when my n=299 but I have to run this program for N=2000.

Is there a routine that anybody knows about that returns just the simple Legendre polynomial of degree n (and order m = 0)?
 
Physics news on Phys.org
The only routine that I know of that might be able to help you is in the Numerical Recipe book. I use the Bessel function routines from this book without any problems.

The website is

www.nr.com

I use the 3rd Edition routines. Be careful, these routines do contain bugs that are hard to find sometimes. In this edition the routine is located in the Spherical Bessel functions section, 6.7.

Thanks
Matt

Thanks
Matt
 
Back
Top