Legendre functions have an important property that is, they are orthogonal on the interval −1 ≤ *x* ≤ 1:

(where δ_{mn} denotes the *Kronecker delta*, equal to 1 if *m* = *n* and to 0 otherwise).

We can verify this result using Scilab.

To work with Legendre Polynomials we use the Scilab function *legendre(n,m,x)*.

Which basically returns the value of the Associated Legendre Polynomial for a given value of m,n and x.

However, since I only wanted Legendre Polynomials so I’ll have to put m=0.

The following code returns the value of the integral, ∫Pm(x)*Pn(x)dx,

//Legendre Polynomials Orthogonality Verification
clc;
n=input("Enter n:");
m=input("Enter m:");
a=integrate('legendre(m,0,x)*legendre(n,0,x)','x',-1,1,0.001);
mprintf('∫P%i(x)*P%f(x)dx= %g\n',m,n,a);

**Output**:

Enter n:1

Enter m:1

∫P1(x)*P1.000000(x)dx= 0.666667

Enter n:5

Enter m:2

∫P2(x)*P5.000000(x)dx= 0

Ph.D. researcher at Friedrich-Schiller University Jena, Germany. I’m a physicist specializing in computational material science. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT, and Machine Learning related apps and software from time to time. Can code in most of the popular languages. I like to share my knowledge in Physics and applications using this Blog and a YouTube channel.

### Like this:

Like Loading...

*Related*

[wpedon id="7041" align="center"]