Feat: Ajoute la comparaison graphique entre sin(x) et l'interpolation avec le polynôme de Newton
This commit is contained in:
22
tp6.py
22
tp6.py
@@ -108,19 +108,35 @@ def exercice2() -> None:
|
|||||||
|
|
||||||
x = [i for i in range(len(x_i))]
|
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 = []
|
results = []
|
||||||
|
real_results = []
|
||||||
|
|
||||||
for i in x:
|
for i in x:
|
||||||
res = P_newton(x_i, [f(x_i[i]) for i in range(len(x_i))], i)
|
res = P_newton(x_i, [f(x_i[i]) for i in range(len(x_i))], i)
|
||||||
print(res)
|
print(res)
|
||||||
|
real_results.append(f(i))
|
||||||
results.append(res)
|
results.append(res)
|
||||||
|
|
||||||
|
print(real_results)
|
||||||
|
|
||||||
plt.plot(results)
|
plt.plot(results)
|
||||||
|
plt.plot(real_results, '-.')
|
||||||
plt.show()
|
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__':
|
if __name__ == '__main__':
|
||||||
exercice1()
|
#exercice1()
|
||||||
#exercice2()
|
exercice2()
|
||||||
|
#exercice3()
|
||||||
|
|||||||
Reference in New Issue
Block a user