How to Calculate Inverse of a 3×3 Matrix

3×3 Matrix Inverse Calculator

Result:

Enter the matrix elements and click "Calculate Inverse".

function calculateMatrixInverse() { var a11 = parseFloat(document.getElementById('a11').value); var a12 = parseFloat(document.getElementById('a12').value); var a13 = parseFloat(document.getElementById('a13').value); var a21 = parseFloat(document.getElementById('a21').value); var a22 = parseFloat(document.getElementById('a22').value); var a23 = parseFloat(document.getElementById('a23').value); var a31 = parseFloat(document.getElementById('a31').value); var a32 = parseFloat(document.getElementById('a32').value); var a33 = parseFloat(document.getElementById('a33').value); var resultDiv = document.getElementById('inverseResult'); // Input validation if (isNaN(a11) || isNaN(a12) || isNaN(a13) || isNaN(a21) || isNaN(a22) || isNaN(a23) || isNaN(a31) || isNaN(a32) || isNaN(a33)) { resultDiv.innerHTML = '

Result:

Please enter valid numbers for all matrix elements.'; return; } // Calculate Determinant var det = a11 * (a22 * a33 – a23 * a32) – a12 * (a21 * a33 – a23 * a31) + a13 * (a21 * a32 – a22 * a31); if (det === 0) { resultDiv.innerHTML = '

Result:

The determinant of the matrix is 0. An inverse does not exist for this matrix.'; return; } // Calculate Cofactor Matrix elements var c11 = (a22 * a33 – a23 * a32); var c12 = -(a21 * a33 – a23 * a31); var c13 = (a21 * a32 – a22 * a31); var c21 = -(a12 * a33 – a13 * a32); var c22 = (a11 * a33 – a13 * a31); var c23 = -(a11 * a32 – a12 * a31); var c31 = (a12 * a23 – a13 * a22); var c32 = -(a11 * a23 – a13 * a21); var c33 = (a11 * a22 – a12 * a21); // Adjugate Matrix (transpose of cofactor matrix) var adj11 = c11; var adj12 = c21; var adj13 = c31; var adj21 = c12; var adj22 = c22; var adj23 = c32; var adj31 = c13; var adj32 = c23; var adj33 = c33; // Inverse Matrix = (1/det) * Adjugate Matrix var inv11 = adj11 / det; var inv12 = adj12 / det; var inv13 = adj13 / det; var inv21 = adj21 / det; var inv22 = adj22 / det; var inv23 = adj23 / det; var inv31 = adj31 / det; var inv32 = adj32 / det; var inv33 = adj33 / det; // Format output to a reasonable number of decimal places var precision = 6; var formatNum = function(num) { return parseFloat(num.toFixed(precision)); }; var output = '

Result:

'; output += 'Determinant (det(A)): ' + formatNum(det) + "; output += 'Inverse Matrix (A⁻¹):'; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += '
' + formatNum(inv11) + '' + formatNum(inv12) + '' + formatNum(inv13) + '
' + formatNum(inv21) + '' + formatNum(inv22) + '' + formatNum(inv23) + '
' + formatNum(inv31) + '' + formatNum(inv32) + '' + formatNum(inv33) + '
'; resultDiv.innerHTML = output; }

Understanding the Inverse of a 3×3 Matrix

The inverse of a matrix is a fundamental concept in linear algebra, crucial for solving systems of linear equations, performing transformations in computer graphics, and various engineering applications. For a square matrix A, its inverse, denoted as A⁻¹, is a matrix such that when multiplied by A, it yields the identity matrix (I). That is, A * A⁻¹ = A⁻¹ * A = I.

Not all matrices have an inverse. A matrix must be square (e.g., 2×2, 3×3, 4×4) and its determinant must be non-zero. If the determinant is zero, the matrix is called singular, and it does not have an inverse.

Why is the Inverse Important?

  • Solving Linear Equations: Just as you can divide by a number to solve an equation like ax = b (giving x = b/a), you can multiply by the inverse matrix to solve matrix equations like AX = B (giving X = A⁻¹B).
  • Geometric Transformations: In computer graphics, matrices are used to represent rotations, scaling, and translations. The inverse matrix can "undo" these transformations.
  • Cryptography: Matrix inverses play a role in encoding and decoding messages.

How to Calculate the Inverse of a 3×3 Matrix

Calculating the inverse of a 3×3 matrix is a multi-step process. For a matrix A:

A = [ a₁₁ a₁₂ a₁₃
a₂₁ a₂₂ a₂₃
a₃₁ a₃₂ a₃₃
]

The formula for the inverse is: A⁻¹ = (1/det(A)) * adj(A)

Where:

  1. det(A) is the determinant of matrix A.
  2. adj(A) is the adjugate (or classical adjoint) of matrix A, which is the transpose of its cofactor matrix.

Step 1: Calculate the Determinant (det(A))

For a 3×3 matrix, the determinant is calculated as:

det(A) = a₁₁(a₂₂a₃₃ – a₂₃a₃₂) – a₁₂(a₂₁a₃₃ – a₂₃a₃₁) + a₁₃(a₂₁a₃₂ – a₂₂a₃₁)

If det(A) = 0, the inverse does not exist.

Step 2: Calculate the Cofactor Matrix (C)

The cofactor Cᵢⱼ for each element aᵢⱼ is found by taking the determinant of the 2×2 submatrix formed by removing row i and column j, and multiplying it by (-1)i+j.

C = [ C₁₁ C₁₂ C₁₃
C₂₁ C₂₂ C₂₃
C₃₁ C₃₂ C₃₃
]

For example:

  • C₁₁ = +(a₂₂a₃₃ – a₂₃a₃₂)
  • C₁₂ = -(a₂₁a₃₃ – a₂₃a₃₁)
  • C₁₃ = +(a₂₁a₃₂ – a₂₂a₃₁)
  • … and so on for all nine elements.

Step 3: Calculate the Adjugate Matrix (adj(A))

The adjugate matrix is the transpose of the cofactor matrix. This means you swap the elements across the main diagonal (rows become columns and columns become rows).

adj(A) = Cᵀ = [ C₁₁ C₂₁ C₃₁
C₁₂ C₂₂ C₃₂
C₁₃ C₂₃ C₃₃
]

Step 4: Calculate the Inverse Matrix (A⁻¹)

Finally, multiply each element of the adjugate matrix by 1/det(A).

A⁻¹ = (1/det(A)) * [ C₁₁ C₂₁ C₃₁
C₁₂ C₂₂ C₃₂
C₁₃ C₂₃ C₃₃
]

Example Calculation

Let's find the inverse of the matrix A:

A = [ 1 2 3
0 1 4
5 6 0
]

  1. Determinant:
    det(A) = 1((1)(0) – (4)(6)) – 2((0)(0) – (4)(5)) + 3((0)(6) – (1)(5))
    det(A) = 1(0 – 24) – 2(0 – 20) + 3(0 – 5)
    det(A) = -24 – 2(-20) + 3(-5)
    det(A) = -24 + 40 – 15 = 1
  2. Cofactor Matrix:
    C₁₁ = +(1*0 – 4*6) = -24
    C₁₂ = -(0*0 – 4*5) = -(-20) = 20
    C₁₃ = +(0*6 – 1*5) = -5
    C₂₁ = -(2*0 – 3*6) = -(-18) = 18
    C₂₂ = +(1*0 – 3*5) = -15
    C₂₃ = -(1*6 – 2*5) = -(6 – 10) = -(-4) = 4
    C₃₁ = +(2*4 – 3*1) = 8 – 3 = 5
    C₃₂ = -(1*4 – 3*0) = -4
    C₃₃ = +(1*1 – 2*0) = 1

    C = [ -24 20 -5
    18 -15 4
    5 -4 1
    ]

  3. Adjugate Matrix (Cᵀ):

    adj(A) = [ -24 18 5
    20 -15 -4
    -5 4 1
    ]

  4. Inverse Matrix (A⁻¹): Since det(A) = 1, A⁻¹ = (1/1) * adj(A) = adj(A).

    A⁻¹ = [ -24 18 5
    20 -15 -4
    -5 4 1
    ]

You can use the calculator above to verify this example or compute the inverse for any other 3×3 matrix.

Leave a Comment