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='P0@P1@P2@P3@P4@P5'); xtitle('The first six Legendre Polynomials') ylabel('Pn(x)'); xlabel('x');
The output:
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.
Thanks a lot for such insightful videos and explanations. These programs proved to be extremely useful. I can’t thank you enough.
Happy to help! Appreciate your feedback.
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
I will try it if I get time. I can’t promise anything though, as I am very occupied these days.
Got some help with Legendre Polynomial. Thank you very much. Need some help with — Second order Differential Equation
• Harmonic oscillator (no friction)
• Damped Harmonic oscillator
• Over damped
• Critical damped
• Oscillatory
• Forced Harmonic oscillator
in scilab
thanks in advance. My mail is [email protected]