diff --git a/ISC_421_Controle_4_Saroukhanian_Iliya.py b/ISC_421_Controle_4_Saroukhanian_Iliya.py index a001bbe8b8aaa1c40cfcee26026323af098487ed..ed058c4884e0d0deb0373233601374f03b8d7d51 100644 --- a/ISC_421_Controle_4_Saroukhanian_Iliya.py +++ b/ISC_421_Controle_4_Saroukhanian_Iliya.py @@ -139,8 +139,6 @@ print() print(f"valeur de la fonction en x = {SD.Taylor_points} : { [SD.f(x) for x in SD.Taylor_points]}") print(f"valeur de la fonction en a et b: {SD.f(SD.a), SD.f(SD.b)}") -# print("===============================") -# print(SD.Maximal_derivatives_values) # Exemple de graphe de la fonction f. # t = np.linspace(SD.a, SD.b, Nmbre_pts) @@ -328,78 +326,6 @@ def plot_errmax_interpolation(): plt.show() -# def caca(): -# print(len(SD.Maximal_derivatives_values)) - - -# ex2_taylor_poly() -# plot_taylor_poly() +plot_taylor_poly() plot_lagrange_poly() -# plot_errmax_interpolation() - - -# def ex3_newton_interpolation_poly(): -# # merce l'ami -# def divided_differences(x, y): -# n = len(y) -# coef = np.zeros([n, n]) -# coef[:, 0] = y -# -# for j in range(1, n): -# for i in range(n - j): -# coef[i, j] = (coef[i + 1, j - 1] - coef[i, j - 1]) / \ -# (x[i + j] - x[i]) -# -# return coef[0, :] -# -# def newton_polynomial(x, x_points, coef): -# n = len(coef) -# p = coef[n - 1] -# for k in range(1, n): -# p = coef[n - k - 1] + (x - x_points[n - k - 1]) * p -# -# return p -# -# nb_points = np.linspace(3, 19, 6, dtype=np.uint64) -# fig, axes = plt.subplots(2, 3, figsize=(20, 12)) -# -# t = np.linspace(SD.a, SD.b, Nmbre_pts) -# -# for i, ax in enumerate(axes.flat): -# chebyshev_points = np.cos( -# (2 * np.arange(nb_points[i]) + 1) / (2 * nb_points[i]) * np.pi) -# -# chebyshev_points_mapped = 0.5 * \ -# (SD.b - SD.a) * (chebyshev_points + 1) + SD.a -# -# interpolate_pts = np.linspace(SD.a, SD.b, nb_points[i]) -# -# y_points_uni = SD.f(interpolate_pts) -# -# coef_uni = divided_differences(interpolate_pts, y_points_uni) -# y_plot_uni = newton_polynomial(t, interpolate_pts, coef_uni) -# -# y_points_cheb = SD.f(chebyshev_points_mapped) -# -# coef_cheb = divided_differences(chebyshev_points_mapped, y_points_cheb) -# y_plot_cheb = newton_polynomial(t, chebyshev_points_mapped, coef_cheb) -# -# ax.plot(t, SD.f(t), color='black', label='f') -# ax.plot(t, y_plot_uni, color='red', -# label='$N_{f}$, intervalle équidistants') -# ax.plot(t, y_plot_cheb, color='blue', -# label='$N_{f}$, points de Chebyshev') -# ax.plot(interpolate_pts, SD.f(interpolate_pts), 'o', color='red', -# label='Points équidistants') -# ax.plot(chebyshev_points_mapped[::-1], -# SD.f(chebyshev_points_mapped[::-1]), 'o', color='blue', -# label='Points de Chebyshev') -# ax.set_title(f'n = {nb_points[i]}') -# ax.set_ylim([-1.2, 1.2]) -# -# ax.legend() -# -# fig.suptitle(f'Polynôme d\'interpolation de Newton de $f$ avec 2 subdivisions différentes d\'intervalle: Équidistantes (rouge) / Points de Chebyshev (bleu)') -# -# fig.tight_layout() -# plt.show() +plot_errmax_interpolation()