Matrix Calculator

Add, subtract, multiply, transpose, and find determinants, inverses, rank, and trace of matrices. Step-by-step solutions with LaTeX and NumPy export.

🔒 Your data stays in your browser

Matrix size:
Matrix A
+
Matrix B

Result: A + B

0
0
0
0

Pro Tips

  • Tab navigation: Press Tab to move between cells in left-to-right, top-to-bottom order.
  • Quick fill: Use the Random button to generate test matrices, or Identity for the identity matrix.
  • Copy results: Copy the result matrix in LaTeX for documents, NumPy for Python code, or JSON for data processing.
  • Step-by-step: Click “Show step-by-step solution” to see exactly how each element is calculated.
  • Inverse check: Multiply a matrix by its inverse to verify you get the identity matrix.

Last updated: March 2026

What Is the Matrix Calculator?

A matrix calculator is a tool that performs arithmetic and algebraic operations on matrices, the rectangular arrays of numbers used throughout mathematics, physics, engineering, computer science, and data science. Instead of manually working through row-by-column multiplication or cofactor expansion, you enter your matrix values and get instant results with full step-by-step breakdowns.

This calculator supports square matrices of size 2x2, 3x3, and 4x4. You can perform two-matrix operations (addition, subtraction, multiplication, scalar multiplication) or single-matrix operations (transpose, determinant, inverse, rank, trace). Every result includes a detailed solution showing exactly how each value was computed, making it ideal for learning linear algebra or verifying homework.

How to Use This Calculator

1. Choose your matrix size. Select 2x2, 3x3, or 4x4 using the size selector at the top. Your existing values are preserved when resizing.

2. Select an operation. Use “Two-Matrix Operations” for A+B, A-B, AxB, or scalar multiplication. Use “Single-Matrix Operations” for transpose, determinant, inverse, rank, or trace.

3. Enter your values. Click any cell and type a number. Use Tab to move to the next cell. Use the Clear, Random, or Identity buttons for quick setup.

4. View your result. Results appear instantly below. Click “Show step-by-step solution” to see the full working. Copy results in plain text, LaTeX, NumPy, or JSON format.

Understanding Matrix Operations

Addition and Subtraction operate element-by-element. Both matrices must be the same size. Each element in the result is the sum (or difference) of the corresponding elements from matrices A and B.

Matrix Multiplication is not element-by-element. Each element of the result is the dot product of a row from A and a column from B. For an n x n matrix, each dot product involves n multiplications and n-1 additions. Matrix multiplication is not commutative: AxB does not generally equal BxA.

Determinant is a scalar value computed from a square matrix. It tells you whether the matrix is invertible (non-zero determinant) and represents the scaling factor of the linear transformation the matrix represents. This calculator uses cofactor expansion for clear, educational step-by-step solutions.

Inverse of a matrix A is the matrix A^(-1) such that A times A^(-1) equals the identity matrix. It exists only when the determinant is non-zero. The calculator uses the direct formula for 2x2 matrices and Gauss-Jordan elimination for larger sizes.

Frequently Asked Questions

What matrix operations does this calculator support?

This calculator supports addition (A+B), subtraction (A−B), multiplication (A×B), scalar multiplication, transpose, determinant, inverse, rank, and trace. All operations work on 2×2, 3×3, and 4×4 square matrices with step-by-step solutions.

How is the matrix determinant calculated?

For 2×2 matrices, the determinant uses the formula ad−bc. For 3×3 and 4×4 matrices, it uses cofactor expansion along the first row. Each cofactor is the product of the element, its sign (−1 raised to i+j), and the determinant of the minor matrix formed by removing that row and column.

When does a matrix inverse not exist?

A matrix inverse does not exist when the determinant is zero. Such a matrix is called singular or non-invertible. This happens when the rows (or columns) are linearly dependent, meaning one row can be expressed as a combination of the others. The calculator detects this and displays an error.

What is the difference between matrix rank and trace?

Rank is the number of linearly independent rows (or columns) in a matrix, found via Gaussian elimination. It tells you the dimension of the column space. Trace is simply the sum of the diagonal elements (a₁₁ + a₂₂ + ...). The trace equals the sum of the eigenvalues.

Can I copy the result for use in LaTeX or Python?

Yes. After every calculation, you can copy the result in four formats: plain text, LaTeX (bmatrix environment), Python/NumPy (np.array), or JSON. Click the corresponding copy button below the result matrix. You can also download a CSV file or copy the full JSON including input matrices and steps.

Related Tools