How to get the inverse of a matrix Julia
Overview
In Julia, matrices can store heterogeneous elements. It dynamically decides the type of the value. In this shot, we will learn how to get the inverse of a matrix using Julia.
The inverse of a matrix is another matrix which, upon multiplication with the given matrix, gives the identity matrix.
For instance, if
We can get the inverse of the matrix in Julia using the inv() function.
Syntax
inv(matrix)
Parameters and return value
It accepts a matrix as a parameter and returns the inverse matrix of it.
Example
Let us take a look at an example.
#give matrixA = [1 -1; 0 2]#get inverse of matrixdisplay(inv(A))
Explanation
In the code snippet above:
- Line 2: We declare and initialize matrix
A. - Line 5: We use the
inv()function to get the inverse of the matrixAand display the returned inverse matrix ofA.