Matrix Addition and Subtraction Calculator

Add or subtract two matrices of the same dimensions instantly — essential for linear algebra, engineering, and data science.

Select the operation, enter both matrices using semicolons for rows and commas for columns, then click Calculate.

Matrix Addition and Subtraction Calculator
Add or subtract two matrices of the same dimensions instantly — essential for linear algebra, engineering, and data science.

Separate rows with semicolons (;) and columns with commas (,). Example: 1,2;3,4 represents a 2×2 matrix.

About the matrix addition and subtraction calculator

Matrix addition and subtraction are among the most fundamental operations in linear algebra. Unlike multiplication, these operations are straightforward: you simply combine corresponding elements from two matrices that share the same dimensions. The requirement for identical dimensions is strict — you cannot add a 2×3 matrix to a 3×2 matrix, even though both contain six elements. To add two matrices A and B, you compute a new matrix C where each element C[i][j] equals A[i][j] + B[i][j]. Subtraction works identically but with a minus sign: C[i][j] = A[i][j] − B[i][j]. Both operations are element-wise, meaning each position in the result depends only on the corresponding positions in the inputs, never on other rows or columns. Matrix addition is commutative (A + B = B + A) and associative ((A + B) + C = A + (B + C)), properties inherited directly from the commutativity and associativity of ordinary real-number addition. Subtraction, however, is not commutative: A − B ≠ B − A in general. The zero matrix — a matrix of all zeros with matching dimensions — plays the role of the additive identity. Adding the zero matrix to any matrix returns the original: A + 0 = A. Every matrix also has an additive inverse, which is the matrix formed by negating every element. Adding a matrix to its inverse always produces the zero matrix. In practice, matrix addition and subtraction appear throughout science and engineering. In image processing, adding two image matrices combines their pixel intensities — useful for blending images. In physics, adding displacement or force vectors in matrix form simplifies calculations involving multiple superimposed fields. In economics, input-output tables are often updated by adding change matrices to existing tables. In machine learning, bias addition in neural networks involves adding a bias matrix to an activation matrix. For students, mastering matrix addition builds the intuition needed for more complex operations such as matrix multiplication, eigenvalue decomposition, and solving systems of linear equations. The element-wise nature of addition also makes it easy to verify by hand, providing a reliable sanity check when working on larger problems. This calculator handles matrices of any consistent dimension, performing all arithmetic in double-precision floating-point for accuracy across a wide range of values.

Matrix addition and subtraction examples

Three worked examples illustrating both addition and subtraction of common matrix types.

InputResultNotes
A = [[1,2],[3,4]], B = [[5,6],[7,8]] — Addition[[6,8],[10,12]]Each element of A is added to the corresponding element of B. C[1][1]=1+5=6, C[1][2]=2+6=8, etc.
A = [[5,6],[7,8]], B = [[1,2],[3,4]] — Subtraction[[4,4],[4,4]]Each element of B is subtracted from the corresponding element of A. C[1][1]=5−1=4, and so on.
A = [[0,1,2],[3,4,5]], B = [[6,5,4],[3,2,1]] — Addition[[6,6,6],[6,6,6]]A 2×3 example. Every pair of elements sums to 6, producing a uniform result matrix.
A = [[2,−1],[0,3]], B = [[−2,1],[0,−3]] — Addition[[0,0],[0,0]]B is the additive inverse of A. Their sum is the 2×2 zero matrix, demonstrating A + (−A) = 0.

How to use the matrix addition and subtraction calculator

  1. Choose the operation — Addition or Subtraction — by clicking the corresponding button at the top of the calculator.
  2. Enter Matrix A in the first field. Use commas to separate values within a row and semicolons to separate rows. For example, type 1,2;3,4 to represent the 2×2 matrix [[1,2],[3,4]].
  3. Enter Matrix B in the second field using the same format. Both matrices must have the same number of rows and columns.
  4. Click Calculate. The result matrix is displayed below, with each element computed from the corresponding pair of input elements.
  5. Click Reset to clear both fields and start a new calculation, or change the operation button to switch between addition and subtraction.

Frequently asked questions

Do both matrices need to be the same size?
Yes. Matrix addition and subtraction are only defined when both matrices have exactly the same dimensions — the same number of rows and the same number of columns. If the dimensions differ, the operation is undefined and the calculator will show an error.
Is matrix addition commutative?
Yes. For any two matrices A and B of the same size, A + B = B + A. This follows directly from the commutativity of ordinary number addition applied element by element. Subtraction is not commutative: A − B ≠ B − A in general.
How do I enter a 3×3 matrix in this calculator?
Type each row separated by a semicolon and each element within a row separated by a comma. For a 3×3 matrix [[1,2,3],[4,5,6],[7,8,9]], enter 1,2,3;4,5,6;7,8,9. The same format applies to any matrix size.
What is the additive inverse of a matrix?
The additive inverse of a matrix A is the matrix −A, formed by negating every element. When you add a matrix to its additive inverse, the result is the zero matrix of the same dimensions. For example, [[1,2],[3,4]] + [[−1,−2],[−3,−4]] = [[0,0],[0,0]].
Can I add matrices with decimal or negative values?
Yes. The calculator accepts any real number including decimals (e.g. 3.14) and negative numbers (e.g. −5). Enter negative numbers using the minus sign before the digit. All arithmetic is performed in double-precision floating-point, ensuring accurate results across a wide range of magnitudes.
What real-world problems use matrix addition?
Matrix addition appears in image blending (adding pixel matrices), physics (superimposing field vectors), economics (updating input-output tables), and machine learning (adding bias terms to activation matrices). Any scenario where two sets of data with the same structure need to be combined element by element can be expressed as matrix addition.