# -*- coding: utf-8 -*- """ Created on Wed Dec 17 15:08:08 2014 @author: grivet Listing 5.3 : calcul du polynĂ´me de Wilkinson """ import numpy as np import matplotlib.pyplot as plt import matplotlib.ticker as mtick def p(x): deg = 12 pp = 1 for i in range(1,deg+1): pp = pp*(x-i) return pp def q(x,k): return p(x) + x**11/2**k x = np.linspace(0.5,12.5,200) plt.plot(x,p(x),"-k",x,q(x,19),"-r",x,q(x,18),"-g",x,q(x,17),"-b") plt.ylim(-2e6,2e6) plt.yticks(np.arange(-2,3)*10**6) # #gca() renvoie un pointeur sur le graphique en cours # plt.gca().yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1e')) plt.title("polynĂ´mes de Wilkinson") plt.show() #plt.gca().yaxis.set_major_formatter(mtick.FormatStrFormatter('%.0e'))