Solve Linear Equations using Jacobi Method

Linear Systems & Numerical Methods DS practice problem on Onlearn.

Difficulty: medium.

Topics: Solve Linear Equations using Jacobi Method, Jacobi Iteration Formula, Diagonal Dominance, Stopping Criteria (e.g., tolerance), Residual Vector Calculation, Vector Norms (e.g., L2 norm), Linear Algebra, Numerical Methods, Computational Mathematics, Algorithm Design & Analysis, Applied Mathematics, Iterative Methods for Linear Systems, Matrix Algebra, Numerical Stability & Convergence, Error Analysis, Computational Complexity.

Write a Python function that uses the Jacobi method to solve a system of linear equations given by Ax = b. The function should iterate n times, rounding each intermediate solution to four decimal places, and return the approximate solution x. Initialize the solution vector x to all zeros before beginning the iterations.