Matrix Operations Explorer

Explore matrix addition, multiplication, transpose, determinant, and inverse for 2×2 matrices

Try these examples:

Matrix Operations Explorer

Matrices are rectangular arrays of numbers that represent linear transformations. Define two 2×22 \times 2 matrices below and explore their arithmetic.

Define Matrix AA

Col 1Col 2
Row 121
Row 201

Define Matrix BB

Col 1Col 2
Row 11-1
Row 211

Addition: A+BA + B

A+B=[0000]A + B = \begin{bmatrix} {\cmv{computed}{sum11}} & {\cmv{computed}{sum12}} \\ {\cmv{computed}{sum21}} & {\cmv{computed}{sum22}} \end{bmatrix}

Multiplication: ABAB vs BABA

AB=[0000]AB = \begin{bmatrix} {\cmv{computed}{prod11}} & {\cmv{computed}{prod12}} \\ {\cmv{computed}{prod21}} & {\cmv{computed}{prod22}} \end{bmatrix}

In general AB≠BAAB \neq BA -- matrix multiplication is not commutative.

BA=[0000]BA = \begin{bmatrix} {\cmv{computed}{ba11}} & {\cmv{computed}{ba12}} \\ {\cmv{computed}{ba21}} & {\cmv{computed}{ba22}} \end{bmatrix}

Determinants

The Unit Square under B, AB and BA

02024xyunit square: area 1B (square): area |det B| = 2AB (square) = A applied after B: area 4BA (square) = B applied after A: area 4
QuantityValue
det⁡(A)\det(A)2
det⁡(B)\det(B)2
det⁡(AB)\det(AB)4
det⁡(A)⋅det⁡(B)\det(A) \cdot \det(B)4

The product property det⁡(AB)=det⁡(A)det⁡(B)\det(AB) = \det(A)\det(B) always holds, and the picture shows why. A matrix sends the unit square to the parallelogram spanned by its columns, and the area of that parallelogram is ∣det⁡∣|\det|. The product ABAB means "apply BB, then AA": BB scales every area by ∣det⁡B∣|\det B|, then AA scales it again by ∣det⁡A∣|\det A|, so the square ends up with area ∣det⁡A∣ ∣det⁡B∣|\det A|\,|\det B|. (The sign of the determinant records whether the square was flipped over.) Applying them in the other order, BABA, usually gives a differently shaped parallelogram, because AB≠BAAB \neq BA, but always one with the same area. Adjust 2 or 1 and watch the areas stay locked together.

Transpose: ATA^T

AT=[0000]A^T = \begin{bmatrix} {\cmv{computed}{a11}} & {\cmv{computed}{a21}} \\ {\cmv{computed}{a12}} & {\cmv{computed}{a22}} \end{bmatrix}

Inverse: A−1A^{-1}

Since det⁡(A)\det(A) = 2 ≠0\neq 0, AA is invertible:

A−1=10[0000]=[0000]A^{-1} = \frac{1}{{\cmv{computed}{detA}}} \begin{bmatrix} {\cmv{computed}{a22}} & {\cmv{computed}{invA12}} \\ {\cmv{computed}{invA21}} & {\cmv{computed}{a11}} \end{bmatrix} = \begin{bmatrix} {\cmv{computed}{inv11}} & {\cmv{computed}{inv12}} \\ {\cmv{computed}{inv21}} & {\cmv{computed}{inv22}} \end{bmatrix}

Try dragging 0 toward a value that makes det⁡(A)=0\det(A) = 0 and watch the inverse vanish.

Summary

PropertyAABB
Trace (a11+a22a_{11}+a_{22})32
Determinant22
Invertible?YesYes

Drag any entry in AA or BB above -- every result on this page updates instantly.

Try it in Code

import numpy as np

A = np.array([[2, 1],
              [0, 1]])
B = np.array([[1, -1],
              [1, 1]])

print("A + B =\n", A + B)
print("\nA @ B =\n", A @ B)
print("\nB @ A =\n", B @ A)
print(f"\ndet(A) = {np.linalg.det(A):.2f}, det(B) = {np.linalg.det(B):.2f}")
print(f"det(AB) = {np.linalg.det(A @ B):.2f}, det(A)*det(B) = {np.linalg.det(A)*np.linalg.det(B):.2f}")
if np.linalg.det(A) != 0:
    print(f"\nA^(-1) =\n{np.round(np.linalg.inv(A), 3)}")

What to explore next

You might also like