Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def myHorner(dd, xp, x):
- n = np.size(xp)
- q = dd
- for k in range(n-1,0, -1):
- q = dd[k-1]+q*(xp-x[k-1])
- return q
- def comparaison(f,a,b,n):
- xx=np.linspace(a,b,n)
- vectab= np.linspace(a,b,n)
- for i in range(1,n):
- x1= a + (i-1)*(b-a)/(n-1)
- x2= (a+b)/2 + ((b-a)/2)*cos((2*i-1)*pi/(2*n))
- df1=diffdiv(x1 , f(x1))
- df2=diffdiv(x2 , f(x2))
- p1 = myhorner(df1,x1,xx)
- p2 = myhorner(df2,x2,xx)
- plt.figure(1)
- plt.subplot(211)
- vectF=f(vectab)
- plt.plot(vectF)
- plt.subplot(212)
- plt.plot(x1,p1,'o',color='red')
- plt.plot(x2,p2,'o',color ='blue')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement