This algorithm will solve a linear system such that the linear operator is diagonally dominant.
Input:
A diagonally dominant matrix \( A \) and a column vector \( b \) compatible with it.
Output:
The solution vector \( x \) such that \( Ax = b \).
Usage/Example:
Here I pre-generate a dummy vector, then operate on it with a tri-diagonal matrix \( A \) to get my \( b \) vector. This means that the solution should be very close to the dummy vector I supplied. As you can see from the output, it works well.
Output:
Implementation/Code:
Jacobi iteration is the continued iteration of:
\[ x_{k+1} = D^{-1} (b - Rx_k) \]
Where \( D \) is the diagonal of \( A \), \( R \) is \( A \) without the diagonal. Luckily, the inverse of a diagonal matrix can be found in \( O(n) \) by inverting every element in the diagonal (or just do nothing if the element is \( 0 \) ). Since matrix multiplication of a column vector takes \( O(n^2) \) operations, this algorithm runs in