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

In summary, The conversation discusses the use of the legendre function in MATLAB to return associated legendre polynomials. The user is looking for a way to get only the simple Legendre polynomial of degrees 0-299 without getting a large array back. They mention using a double for loop and running the program for n = 2000. The other person suggests checking the Numerical Recipe book for a routine that could help and shares their experience using the book's Bessel function routines. They also mention the possible presence of bugs in the routines. The conversation ends with both parties thanking each other.
  • #1
Somefantastik
230
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
  • #2
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
 
  • #3


Thank you for your question. It is great to hear that you are using MATLAB to work with Legendre polynomials. To address your concern, I would suggest looking into the MATLAB function "legendreP". This function returns the Legendre polynomial of degree n and order m, where m=0 is the simple Legendre polynomial. This way, you can avoid getting a large array back and only get the specific polynomial you need for your calculations. Additionally, you can also use the "legendreP" function within your double for loop to efficiently iterate through the desired degrees. I hope this helps and wish you success in your research.
 

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

What are MATLAB Legendre Polynomials?

MATLAB Legendre Polynomials are a set of orthogonal polynomials that are commonly used in mathematics and physics. They are named after the French mathematician Adrien-Marie Legendre and are denoted by Pn(x), where n is the degree of the polynomial and x is the variable.

What is the purpose of using MATLAB Legendre Polynomials?

MATLAB Legendre Polynomials are used to approximate functions and solve differential equations. They are also used in numerical analysis, signal processing, and image processing.

How are MATLAB Legendre Polynomials calculated?

The MATLAB built-in function legendre is used to compute Legendre polynomials. It takes two input arguments, the degree of the polynomial and the variable x, and returns a vector containing the values of the polynomial at different points.

What are the properties of MATLAB Legendre Polynomials?

MATLAB Legendre Polynomials have several important properties, including orthogonality, recurrence relation, and generating function. These properties make them useful for solving various mathematical problems and for numerical computations.

Can MATLAB Legendre Polynomials be visualized?

Yes, MATLAB has built-in functions for plotting Legendre polynomials. The plot function can be used to visualize the polynomial curve, and the stem function can be used to plot the polynomial coefficients.

Similar threads

Back
Top