%matplotlib inline
%config InlineBackend.figure_format = 'svg'
import numpy as np
import matplotlib.pyplot as plt
def chebyshev(n, x):
if n == 0:
y = np.ones(len(x))
elif n == 1:
y = x.copy()
else:
y = 2*x*chebyshev(n-1,x) - chebyshev(n-2,x)
return y
N = 200
x = np.linspace(-1.0,1.0,N)
plt.figure(figsize=(8,6))
for n in range(0,6):
y = chebyshev(n,x)
plt.plot(x,y)
plt.grid(True)
plt.xlabel('x')
plt.ylabel('$T_n(x)$');