# -*- coding: utf-8 -*- """ Created on Tue Dec 16 12:09:51 2014 @author: grivet Exercice 4-5 : Construction d'une table de différences latérales """ import numpy as np blanc = " " nval = eval(input("nombre de valeurs de la fonction: ")) dmax = eval(input("ordre maximal des differences: ")) xi = float(input("valeur initiale de l'argument: ")) h = float(input("intervalle tabulaire: ")) table = np.zeros([nval,dmax+1]) #création d'une tabe de valeurs x = xi for i in range(nval): table[i,0] = np.sqrt(x) x = x + h #remplissage de la table for j in range(1,dmax+1): for i in range(j,nval): table[i,j] = table[i,j-1] - table[i-1,j-1] x = xi for i in range(nval): #lignes impaires k = 0; l = i print ('%4.1f' %x,end = '') while (k <= dmax) & (l < nval): if k <= l: print ('%12.4f' %table[l,k],end = '') print (blanc,end = '') k = k+2; l = l+1 print() #lignes paires x += h k = 1; l = i+1 print (' ',end = '') while (k <= dmax) & (l < nval): if k <= l: print ('%s%12.4f' %(blanc,table[l,k]),end = '') k += 2; l += 1 print()