Jacobi iteration method in C

In this article, we will discuss the Jacobi iteration method in C with its multiple examples.

What is the Jacobi Iteration Method?

Jacobi iteration is an approach for numerically solving systems of linear equations. It approximates the solution through successive iterations and falls under the category of iterative methods. Because of the memory and computational costs associated with large sparse systems, the method is especially helpful in these situations, where more direct approaches like Gaussian elimination are not feasible.

In the process of resolving Jacobi iteration entails dissecting the equation Ax=b, where A is a square matrix of coefficients, x is the vector of unknowns, and b is the vector of constants, into a sequence of updates for each variable.

In order to begin this method, make an initial estimate of x(0). Use the following equation to determine the updated value of each variable xi in x:

Jacobi iteration method in C

Example 1:

Let us take an example to illustrate the Jacobi Iteration Method in C.

Output:

 
Solution after 41 iterations:
x[0] = 1.000000
x[1] = 0.999999
x[2] = 1.000000

Example 2:

Let us take another example to illustrate the Jacobi Iteration Method in C.

Output:

 
Solution after 16 iterations:
x[0] = 3.750000
x[1] = 3.000000
x[2] = 2.250000