Convert | Msor To Sor
Wait — this yields a negative ( \omega ), which is invalid for SOR (must be between 0 and 2). This reveals an important insight: .
For many practical problems (e.g., Poisson's equation on a grid), the optimal SOR parameter is related to the spectral radius of the Jacobi method (( \mu )): [ \omega_opt^SOR = \frac21 + \sqrt1-\mu^2 ] convert msor to sor
Consider the Poisson equation on a rectangular grid with red-black ordering. The MSOR iteration matrix ( \mathcalL MSOR(\omega_1, \omega_2) ) is similar to the SOR iteration matrix ( \mathcalL SOR(\omega) ) if: Wait — this yields a negative ( \omega
[ \omega_SOR = \frac21 + \sqrt1 - \left( \frac\omega_1 + \omega_2 - \omega_1 \omega_2\omega_1 + \omega_2 - 1 \right)^2 ] x) - A[i
def sor_solve(A, b, omega, tol=1e-6, max_iter=1000): n = len(b) x = np.zeros_like(b) for _ in range(max_iter): x_old = x.copy() for i in range(n): sigma = np.dot(A[i, :], x) - A[i, i] * x[i] x[i] = (1 - omega) * x[i] + (omega / A[i, i]) * (b[i] - sigma) if np.linalg.norm(x - x_old) < tol: break return x A = np.array([[4, -1, 0], [-1, 4, -1], [0, -1, 4]], dtype=float) b = np.array([1, 2, 3]) Old MSOR call x_msor = msor_solve(A, b, omega1=1.2, omega2=1.8) Converted SOR call - choose an effective omega omega_effective = 1.5 # Based on heuristic x_sor = sor_solve(A, b, omega=omega_effective) Handling the Parameter Conversion If you don’t have a heuristic, run a small calibration loop:
[ \omega_SOR^(effective) = \frac\omega_1 + \omega_22 \quad \text(experimental, low accuracy) ]