1 import matplotlib.pyplot as plt
8 diff_div=[[0 for _ in xrange(n+1)] for _ in xrange(n+1)]
11 for j in xrange(1,n+1):
12 for i in xrange(n-j+1):
13 r = float(diff_div[i+1][j-1]-diff_div[i][j-1])/(X[i+j]-X[i])
19 print "TP 2.1 ............"
29 def construit_pol(X,Y):
32 return lambda x : sum([d[i]*forloop([x - X[j] for j in xrange(i)]) for i in xrange(n+1)])
39 p = construit_pol(X,Y)
47 x=np.linspace(10,100,100)
49 plt.ylabel('temps d\'execution')
50 plt.xlabel("taille des donnees")
58 X1 = [-1+0.25*i for i in xrange(9)]
59 Y1 = [e**x for x in X1]
60 p1 = construit_pol(X1,Y1)
63 X2 = [cos(pi/2*(float(2*i+1)/9)) for i in xrange(9)]
64 Y2 = [e**x for x in X2]
65 p2 = construit_pol(X2,Y2)
69 e1 = lambda x : abs(p1(x) - e**x)
70 e2 = lambda x : abs(p2(x) - e**x)
71 x=np.linspace(-1,1,1000)