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
Explanation / Answer
#include #include float detrm(float[][],float); void cofact(float[][],float); void trans(float[][],float[][],float); main() { float a[25][25],k,d; int i,j; printf("ENTER THE ORDER OF THE MATRIX: "); scanf("%f",&k); printf("ENTER THE ELEMENTS OF THE MATRIX: "); for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.