The inverse of a square matrix A is denoted A-1, such that A×A-1 = I, where I is
ID: 3634498 • Letter: T
Question
The inverse of a square matrix A is denoted A-1, such that A×A-1 = I, where I is the identity matrix with all 1’s on the diagonal and 0 on all other cells. The inverse of matrix , for example, isthat is,
The inverse of a 3 × 3 matrix
can be obtained using the following formula if :
.
Implement the following function to obtain an inverse of the matrix:
public static double[][] inverse(double[][] A)
Write a test program that prompts the user to enter , , , , , , , , for a matrix and displays its inverse matrix. Here are the sample runs:
Sample 1
Enter a11, a12, a13, a21, a22, a23, a31, a32, a33: 1 2 1 2 3 1 4 5 3
-2 0.5 0.5 1 0.5 -0.5 1 -1.5 0.5
Sample 2
Enter a11, a12, a13, a21, a22, a23, a31, a32, a33: 1 4 2 2 5 8 2 1 8
2.0 -1.875 1.375
0.0 0.25 -0.25
-0.5 0.4375 -0.1875