# -*- coding: utf-8 -*- """ Created on Wed Jan 07 14:43:25 2015 @author: grivet Listing 7.1 : Polynômes de Laguerre calculés par récurrence ou tirés de la bibliothèque Scipy """ import numpy as np from scipy.special import * import matplotlib.pyplot as plt def L(n,x): if n == 0: return 1 elif n == 1: return 1-x else: k = 1; Lavder = 1; Lder = 1-x while k < n: L = ((2*k+1-x)*Lder - k*Lavder)/(k+1) Lavder = Lder Lder = L k += 1 return L x = np.linspace(0,6,100) plt.plot(x,L(5,x),label="n = 5") plt.plot(x,L(4,x),label="n = 4") plt.plot(x,L(3,x),label="n = 3") #plt.plot(x,zeros_like(x),'-k') plt.title('Polynomes de Laguerre, n = 3,4,5,6') plt.xlabel('$x$',fontsize=20) plt.ylabel('$L_n(x)$',fontsize=20) plt.plot(x,eval_laguerre(6,x),label="n = 6") plt.show() plt.legend()