<jupyter_start><jupyter_text>Phénomène de Runge![runge](docs/runge.png)Plus il y a de points, plus les imprécisions sur le côté sont importantes.<jupyter_code># import
import numpy as np # maths
import matplotlib.pyplot as plt # graph

def f(x): # function f
    return 1./(1.+25*x**2)

xx = np.linspace(-1, 1, 1000) # 1000 points between -1 and 1
yy = f(xx) # function values
# Show the interpolation with 10
x = np.linspace(-1, 1, 11)
y = f(x)
a = np.polyfit(x, y, 10)
p = np.polyval(a, xx)
plt.plot(xx, p, 'r', xx, yy, 'b', x, y, 'o')
plt.show()
# show the interpolation with 20
x = np.linspace(-1, 1, 21)
y = f(x)
a = np.polyfit(x, y, 20)
p = np.polyval(a, xx)
plt.plot(xx, p, 'r', xx, yy, 'b', x, y, 'o')
plt.show()
# show the interpolation with 30
x = np.linspace(-1, 1, 31)
y = f(x)
a = np.polyfit(x, y, 30)
p = np.polyval(a, xx)
plt.plot(xx, p, 'r', xx, yy, 'b', x, y, 'o')
plt.show()<jupyter_output><empty_output><jupyter_text>Chaque fois que l'on ajoute un point, l'oscillation augmente au extrémité de la courbe.Essayons avec moins de points.<jupyter_code># show the interpolation with 5
x = np.linspace(-1, 1, 6)
y = f(x)
a = np.polyfit(x, y, 5)
p = np.polyval(a, xx)
plt.plot(xx, p, 'r', xx, yy, 'b', x, y, 'o')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18181818181818182, 'fraction_numerical': 0.03636363636363636, 'mean_word_length': 4.188524590163935, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '372275', 'license': 'MIT', 'n_tokens_mistral': 614, 'n_tokens_neox': 564, 'n_words': 176, 'path': 'interpolation/polynomial/runge.ipynb', 'repo_name': 'simbarras/maths-spe', 'size': '1265'}