Java Program to Find Inverse of a Matrix

Here you will get java program to find inverse of a matrix of order 2×2 and 3×3.

We can find inverse of a matrix in following way.

  • First find the determinant of matrix.
  • Calculate adjoint of matrix.
  • Finally divide adjoint of matrix by determinant.

Java Program to Find Inverse of a Matrix

Image Source

Below I have shared program to find inverse of 2×2 and 3×3 matrix.

Java Program to Find Inverse of a Matrix

2×2 Matrix

Output

Enter elements of matrix row wise:
4 7
2 6

determinant = 10.0

Inverse of matrix is:
0.6 -0.7
-0.2 0.4

3×3 Matrix

Output

Enter elements of matrix row wise:
1 2 3
0 1 4
5 6 0

determinant = 1.0

Inverse of matrix is:
-24.0 18.0 5.0
20.0 -15.0 -4.0
-5.0 4.0 1.0

Comment below if you have any queries related to above program to find inverse of matrix in java.

Leave a Reply

Your email address will not be published. Required fields are marked *