Fix: Correct dichotimie

This commit is contained in:
Namu
2025-10-19 21:03:35 +02:00
parent 128e07d420
commit b559ade3e9
2 changed files with 14 additions and 15 deletions

5
ex3.py
View File

@@ -72,11 +72,8 @@ def relaxation(A, b, omega=1.0, epsilon=1e-6, max_iter=100_000):
# Pré-calculer (D - ωL)^(-1) une seule fois
inv_D_omega_L = np.linalg.inv(D - omega * L)
if omega == 1:
return gauss_seidel(A, b)
for _ in range(max_iter):
x_new = inv_D_omega_L @ ((1 - omega) * D @ x + omega * (U @ x + b))
x_new = inv_D_omega_L @ (omega * (b - U @ x) - omega * L @ x + (1 - omega) * D @ x)
if np.linalg.norm(x_new - x, ord=2) < epsilon:
return x_new
x = x_new