Feat: Ajoute la comparaison graphique entre sin(x) et l'interpolation avec le polynôme de Newton

This commit is contained in:
Namu
2026-01-07 14:35:53 +01:00
parent 6df3d06ff0
commit 51fd37f80b

22
tp6.py
View File

@@ -108,19 +108,35 @@ def exercice2() -> None:
x = [i for i in range(len(x_i))]
f = lambda x : np.sin(x)
f = lambda input_of_f : np.sin(input_of_f)
results = []
real_results = []
for i in x:
res = P_newton(x_i, [f(x_i[i]) for i in range(len(x_i))], i)
print(res)
real_results.append(f(i))
results.append(res)
print(real_results)
plt.plot(results)
plt.plot(real_results, '-.')
plt.show()
def exercice3() -> None:
t = [1.5, 3.5, 4.5, 11, 12, 13]
h = [80, 160, 184, 184, 149, 116]
# fonction de calcul de h
f_h = lambda a, b, c, t: a * (t ** 2) + b * t + c
print(f'{f_h(1,2,3,t[0])}')
if __name__ == '__main__':
exercice1()
#exercice2()
#exercice1()
exercice2()
#exercice3()