Refactor: Ajoute de la documentation et de nouvelle implémentation pour les méthodes de calcul d'intervalle

This commit is contained in:
Namu
2026-01-18 23:47:06 +01:00
parent 428a9db530
commit f6c69efb16
3 changed files with 146 additions and 7 deletions

26
tp8.py Normal file
View File

@@ -0,0 +1,26 @@
import matplotlib.pyplot as plt
def euler(f, n: int, delta_x: float, x_0: float, y_0: float) -> list[float]:
results = []
x = x_0
y = y_0
for i in range(n):
x = x + delta_x
y = y + delta_x * f(x, y)
results.append(y)
return results
def exercice1() -> None:
f = lambda x, y: -2 * x * y + 1
results = euler(f, n=20, x_0=0, y_0=1, delta_x=.2)
plt.plot(results)
plt.title('Euler')
plt.show()
if __name__ == '__main__':
exercice1()