answersLogoWhite

0

Inverse of matrix in java

Updated: 10/25/2022
User Avatar

Wiki User

13y ago

Best Answer

import java.util.Scanner;

public class Exercise07_23 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("Enter a11, a12, a13, a21, a22, a23, a31, a32, a33: ");

double[][] A = new double[3][3];

for (int i = 0; i < 3; i++)

for (int j = 0; j < 3; j++)

A[i][j] = input.nextDouble();

double[][] inverseOfA = inverse(A);

printMatrix(inverseOfA);

}

public static void printMatrix(double[][] m) {

// ????

}

public static double[][] inverse(double[][] A) {

double[][] result = new double[A.length][A.length];

// Compute |A|

double determinantOfA = 1; // A[0][0] * A[1][1] * A[2][2] * ...;

result[0][0] = (A[1][1] * A[2][2] - A[1][2] * A[2][1]) / determinantOfA;

result[0][1] = 1; // ??

result[0][2] = 1; // ??

result[1][0] = 1; // ??

return result;

}

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Inverse of matrix in java
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you write a java program to find the transpose of the matrix for the given elements?

You basically write a nested for loop (one for within another one), to copy the elements of the matrix to a new matrix.


Write a c program to determine whether a matrix is singular or not?

A c program is also known as a computer program. A singular matrix has no inverse. An equation to determine this would be a/c=f. &lt;&lt;&gt;&gt; The determinant of a singular matix is zero.


How do you write a java package program for addition?

A number of well-tested open-source Matrix Java libraries are available. Best to find and use one that's been around for a while since most of the bugs have been worked out. If you need to write your own it's still worth-while to examine the APIs of those libraries first.JAMA is a free Java library for basic linear algebra and matrix operations developed as a straightforward public-domain reference implementation by MathWorks and NIST.Example of Use. The following simple example solves a 3x3 linear system Ax=b and computes the norm of the residual.double[][] array = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}};Matrix A = new Matrix(array);Matrix b = Matrix.random(3,1);Matrix x = A.solve(b);Matrix Residual = A.times(x).minus(b);double rnorm = Residual.normInf();


How can you write a program which proves that a multiple of a matrix and its determinant is an identity matrix?

Automated proofs are a complicated subject. If you are not an expert on the subject, all you can hope for is to write a program where you can input a sample matrix (or that randomly generates one), and verifies the proposition for this particular case. If the proposition is confirmed in several cases, this makes the proposition plausible, but is by no means a formal proof.Better try to prove it without writing any program.Note: it is not even true; it is the inverse of the matrix which gives identity when is multiplied with the original matrix.


What is the inverse of resistance?

The inverse of resistance is conductance.

Related questions

What is leontief inverse matrix?

(I-A)-1 is the Leontief inverse matrix of matrix A (nxn; non-singular).


Is Inverse of the inverse matrix the original matrix?

Let A by an nxn non-singular matrix, then A-1 is the inverse of A. Now (A-1 )-1 =A So the answer is yes.


How are the inverse matrix and identity matrix related?

If an identity matrix is the answer to a problem under matrix multiplication, then each of the two matrices is an inverse matrix of the other.


Does every square matrix have an inverse?

No. A square matrix has an inverse if and only if its determinant is nonzero.


Define inverse of matrix?

From Wolfram MathWorld: The inverse of a square matrix A, sometimes called a reciprocal matrix, is a matrix A-1 such that AA-1=I where I is the identity matrix.


What are the applications of det of a matrix?

it is used to find the inverse of the matrix. inverse(A)= (adj A)/ mod det A


How do you find a variable in a matrix if there is no inverse?

The fact that the matrix does not have an inverse does not necessarily mean that none of the variables can be found.


How do you call a matrix that if you multiplied it by the original matrix you would get the identity matrix?

That is called an inverse matrix


Which matrix has no multiplicative inverse?

A rectangular (non-square) matrix.


How to find the inverse of a square matrix?

You can factorize the matrix using LU or LDLT factorization algorithm. inverse of a diagonal matrix (D) is really simple. To find the inverse of L, which is a lower triangular matrix, you can find the answer in this link.www.mcs.csueastbay.edu/~malek/TeX/Triangle.pdfSince (A T )-1 = (A-1 )T for all matrix, you'll just have to find inverse of L and D.


How to find the inverse of a symmetric matrix?

You can factorize the matrix using LU or LDLT factorization algorithm. inverse of a diagonal matrix (D) is really simple. To find the inverse of L, which is a lower triangular matrix, you can find the answer in this link.www.mcs.csueastbay.edu/~malek/TeX/Triangle.pdfSince (A T )-1 = (A-1 )T for all matrix, you'll just have to find inverse of L and D.


How to find the Inverse of a square symmetric matrix?

You can factorize the matrix using LU or LDLT factorization algorithm. inverse of a diagonal matrix (D) is really simple. To find the inverse of L, which is a lower triangular matrix, you can find the answer in this link.www.mcs.csueastbay.edu/~malek/TeX/Triangle.pdfSince (A T )-1 = (A-1 )T for all matrix, you'll just have to find inverse of L and D.