';return html;}function calculateInverse(){var size=document.getElementById('matrix_size').value;var ansDiv=document.getElementById('answer');var resBox=document.getElementById('calculatorAnswer');if(size==='2′){var a=parseFloat(document.getElementById('m2_00').value);var b=parseFloat(document.getElementById('m2_01').value);var c=parseFloat(document.getElementById('m2_10').value);var d=parseFloat(document.getElementById('m2_11').value);if(isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)){alert('Please fill all fields');return;}var det=a*d-b*c;if(Math.abs(det)<1e-10){ansDiv.innerHTML="Determinant is 0. This matrix is singular and has no inverse.";resBox.style.display='block';return;}var inv=[d/det,-b/det,-c/det,a/det];var formatted=[];for(var i=0;i<4;i++)formatted.push(toFrac(inv[i]));ansDiv.innerHTML="
Determinant (Δ) = "+det.toFixed(4)+"
"+formatMatrix(formatted,2);}else{var m=[[0,0,0],[0,0,0],[0,0,0]];for(var r=0;r<3;r++){for(var c=0;c<3;c++){var val=parseFloat(document.getElementById('m3_'+r+c).value);if(isNaN(val)){alert('Please fill all fields');return;}m[r][c]=val;}}var det=m[0][0]*(m[1][1]*m[2][2]-m[1][2]*m[2][1])-m[0][1]*(m[1][0]*m[2][2]-m[1][2]*m[2][0])+m[0][2]*(m[1][0]*m[2][1]-m[1][1]*m[2][0]);if(Math.abs(det)<1e-10){ansDiv.innerHTML="Determinant is 0. This matrix is singular and has no inverse.";resBox.style.display='block';return;}var inv=[];inv.push((m[1][1]*m[2][2]-m[1][2]*m[2][1])/det);inv.push(-(m[0][1]*m[2][2]-m[0][2]*m[2][1])/det);inv.push((m[0][1]*m[2][2]-m[0][2]*m[2][1])/det);/* Wait cofactors transposed */inv=[(m[1][1]*m[2][2]-m[1][2]*m[2][1])/det,-(m[0][1]*m[2][2]-m[0][2]*m[2][1])/det,(m[0][1]*m[1][2]-m[0][2]*m[1][1])/det,-(m[1][0]*m[2][2]-m[1][2]*m[2][0])/det,(m[0][0]*m[2][2]-m[0][2]*m[2][0])/det,-(m[0][0]*m[1][2]-m[0][2]*m[1][0])/det,(m[1][0]*m[2][1]-m[1][1]*m[2][0])/det,-(m[0][0]*m[2][1]-m[0][1]*m[2][0])/det,(m[0][0]*m[1][1]-m[0][1]*m[1][0])/det];var formatted=[];for(var i=0;i<9;i++)formatted.push(toFrac(inv[i]));ansDiv.innerHTML="
This inverse matrix calculator helps you find the inverse of a square matrix (2×2 or 3×3) using the Gaussian elimination or Adjugate method. Matrix inversion is a fundamental operation in linear algebra, used to solve systems of linear equations, transform coordinate systems, and in various engineering simulations.
To use the calculator, simply select the dimensions of your matrix, enter the numerical values into the grid, and click "Calculate Inverse". The tool will provide the determinant and the resulting inverse matrix.
Matrix Size
Choose between a 2×2 or 3×3 square matrix. Only square matrices (where rows equal columns) can have an inverse.
Determinant (Δ)
The calculator first finds the determinant. If the determinant is zero, the matrix is "singular" and does not have an inverse.
Fractions vs Decimals
You can toggle the output to show exact fractions, which is often preferred in academic settings, or decimal approximations.
How It Works
For a matrix A, its inverse A⁻¹ is a matrix such that A × A⁻¹ = I, where I is the identity matrix. The standard formula for a 2×2 matrix is:
A⁻¹ = (1 / det(A)) * adj(A)
Determinant (det): For 2×2 [[a, b], [c, d]], the determinant is (ad – bc).
Adjugate (adj): For 2×2, swap the main diagonal elements (a and d) and change the signs of the off-diagonal elements (b and c).
Scalar Multiplication: Multiply every element of the adjugate matrix by (1/det).
Calculation Example
Example: Find the inverse of a 2×2 matrix where A = [[4, 7], [2, 6]].
Find Adjugate: Swap 4 and 6, negate 7 and 2 → [[6, -7], [-2, 4]]
Multiply by 1/Det: [[6/10, -7/10], [-2/10, 4/10]]
Final Result: [[0.6, -0.7], [-0.2, 0.4]]
Common Questions
What is a singular matrix?
A singular matrix is a square matrix that does not have an inverse. This occurs when the determinant of the matrix is exactly zero. In geometric terms, this means the transformation associated with the matrix collapses the space into a lower dimension.
Why can only square matrices be inverted?
The definition of an inverse requires that A multiplied by A⁻¹ equals the identity matrix I. Since the identity matrix is always square, and matrix multiplication dimensions must align, only square matrices can satisfy this property in both directions (left and right inverse).
Is there a faster way for 3×3 matrices?
For 3×3 matrices, the Adjugate method (using cofactors and transposing) is standard for manual calculation, but computer algorithms often use Gaussian elimination with partial pivoting or LU decomposition for better efficiency and numerical stability.