Plotting the First 6 LEGENDRE Polynomials 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 calculates and plots the first six Legendre Polynomials for x=-1 to x=1.

//Legendre Polynomials 
//The following codes prints the first six Legendre Polynomials(P0,P1,P2,...P5).
clc;
clf;
n=0:5;
x=[-1:0.001:1]';
y=legendre(n,0,x)';
plot2d(x,y,leg='[email protected]@[email protected]@[email protected]');
xtitle('The first six Legendre Polynomials')
ylabel('Pn(x)');
xlabel('x');

The output:

legendre first 6 polynomials plot graph

Legendre Polynomials(lab college)

PhD researcher at Friedrich-Schiller University Jena, Germany. I'm a physicist specializing in theoretical, computational and experimental condensed matter physics. I like to develop Physics related apps and softwares from time to time. Can code in most of the popular languages. Like to share my knowledge in Physics and applications using this Blog and a YouTube channel.



4 thoughts on “Plotting the First 6 LEGENDRE Polynomials using Scilab

  1. Thanks a lot for such insightful videos and explanations. These programs proved to be extremely useful. I can’t thank you enough.

  2. Can you help me ? I tried to obtain the plot of five first Hermite polynomial using Scilab but I failed. If someone know it, please send the code

    1. I will try it if I get time. I can’t promise anything though, as I am very occupied these days.

Leave a Reply

Your email address will not be published. Required fields are marked *