Audited 29 Jul 2026·Last updated 31 Jul 2026·6 citations·Tier 1·0 uses

Matrix Calculator

Free matrix calculator for A + B, A − B, k·A and the linear combination αA + βB. Exact decimal arithmetic, dimension checks and a worked 2×2 example.

Matrix Calculator

Operation
One row per line. Separate entries with spaces or commas. Max 10 × 10.
Must have exactly the same dimensions as A. Ignored in scalar mode.
Read in scalar and linear-combination modes. Forced to 1 for A + B and A − B.
Read in linear-combination mode only. Forced to +1 for A + B and −1 for A − B.
Result matrix
[6 8; 10 12]
The entry-wise result, rows separated by semicolons. This page adds, subtracts and scales matrices — for the product A×B, for powers, for the transpose or for the inverse, use the linked calculators.
Rows
2
Columns
2
Sum of entries
36
Largest magnitude
12

Background.

The Quanta matrix calculator does the arithmetic that treats a matrix as a single object: it adds two matrices, subtracts one from another, multiplies a matrix by a scalar, and evaluates the general linear combination αA + βB, all in exact decimal arithmetic and all with the dimension checks done for you. Enter each matrix one row per line — spaces or commas between entries, up to 10 × 10 — pick an operation, and the result comes back as a readable matrix along with its dimensions, the sum of its entries and its largest magnitude, so you can sanity-check the answer without retyping it anywhere.

It is worth being precise about what this page covers, because "matrix calculator" is asked to mean several different things. Everything here is entry-wise: the result's (i, j) entry depends only on the (i, j) entries of the inputs. That is exactly true of addition, subtraction and scalar multiplication, and it is why those three operations require the two matrices to have identical dimensions and never change the shape of the answer. The matrix product A×B is a different animal — it mixes whole rows with whole columns, it needs the inner dimensions to agree rather than all four, and it is not commutative — so it has its own calculator, as do matrix powers, the transpose and the inverse. Every one of those is linked from this page. If you came here to multiply two matrices together, the matrix multiplication calculator is one click away.

Entry-wise arithmetic looks trivial, and mechanically it is; the reason it matters is structural. Matrix addition and scalar multiplication are what make the set of all m × n matrices a vector space. Addition is commutative and associative, the zero matrix is an additive identity, every matrix A has an additive inverse −A, and scalar multiplication distributes over both matrix addition and scalar addition. Those axioms are the licence for every algebraic move you make later: they are why you can rearrange A + B − C freely, why 3(A + B) = 3A + 3B, why a least-squares residual can be written as a difference of matrices, and why the whole apparatus of linear maps, bases and dimension gets off the ground. Cayley's 1858 memoir, the paper that founded matrix algebra as a subject, opens with exactly these definitions before it ever reaches multiplication.

The practical uses are everywhere once you look. In image processing, adding two matrices of pixel values blends two frames and subtracting them isolates what moved between them — the basis of every motion-detection routine. In accounting and operations research, a linear combination αA + βB blends two scenario tables with chosen weights. In statistics, a covariance shrinkage estimator is literally αS + βT, a weighted blend of a sample covariance matrix and a structured target. In physics and engineering, superposing two stress or stiffness contributions is matrix addition, and rescaling a system for a change of units is scalar multiplication. In machine learning, a gradient-descent step subtracts a scaled gradient matrix from a weight matrix — which is the linear-combination mode of this page, with α = 1 and β equal to the negative learning rate.

The calculator uses arbitrary-precision decimal arithmetic rather than binary floating point, so entering 0.1 and 0.2 gives you exactly 0.3 instead of 0.30000000000000004, and it rounds only once, at the end, to ten decimal places. It tells you which row a bad entry is on, refuses ragged input where one row has more entries than another, and refuses to add a 2 × 3 to a 2 × 2 while printing both shapes so you can see immediately which one you mistyped.

What is matrix calculator?

A matrix is a rectangular array of numbers arranged in m rows and n columns, written A = (aᵢⱼ), where aᵢⱼ is the entry in row i and column j. Matrix arithmetic is the set of rules for combining such arrays. Three of those rules are entry-wise, and they are what this calculator implements. Addition: if A and B have the same dimensions, A + B is the matrix whose (i, j) entry is aᵢⱼ + bᵢⱼ. Subtraction is the same operation with the signs flipped, A − B = A + (−1)B. Scalar multiplication: for a number α, the matrix αA has entries α·aᵢⱼ. Encyclopedia of Mathematics states the first and third of these verbatim — "the sum of the matrices A and B is, by definition, A+B = (a_ij+b_ij)" and "the product of the matrix A by the element (number, scalar) α is, by definition, the matrix αA = (α a_ij)". Composing them gives the general linear combination αA + βB, whose (i, j) entry is α·aᵢⱼ + β·bᵢⱼ; that single expression covers all three operations, since α = β = 1 gives addition, β = −1 gives subtraction, and β = 0 gives a scalar multiple. The dimension requirement is not a technicality: entry-wise operations pair up entries by position, so a position that exists in one matrix and not the other has nothing to pair with, and the operation is simply undefined. This is the sharpest difference between entry-wise arithmetic and the matrix product, which is defined whenever the inner dimensions agree — an m × n matrix times an n × p matrix — and which produces an m × p result whose shape usually differs from both inputs. Because addition and scalar multiplication satisfy the eight vector-space axioms, the set of all m × n matrices over a field is itself a vector space of dimension m·n, with the matrices that have a single 1 and zeros elsewhere as a natural basis. That fact is what lets you treat matrices as vectors when it is convenient — in optimisation, in statistics, in the theory of linear maps — and it is a direct consequence of the two definitions above.

How to use this calculator.

  1. Pick the operation at the top. "A + B" and "A − B" combine two matrices of the same size. "α · A" scales a single matrix by a number. "αA + βB" is the general form and covers all three.
  2. Type Matrix A into the first box, one row per line. Separate the entries in a row with spaces or commas — "1 2" then "3 4" on the next line, or "1,2;3,4" all on one line, both give the same 2 × 2 matrix. The ceiling is 10 rows by 10 columns.
  3. Type Matrix B the same way if your mode needs it. It must have exactly the same number of rows and columns as A; if it does not, the calculator says so and prints both shapes. In scalar mode Matrix B is ignored entirely, so you can leave whatever is in it.
  4. Set the coefficients if your mode reads them. α is the scalar k in scalar mode and the weight on A in linear-combination mode. β is the weight on B and is only read in linear-combination mode. In A + B and A − B the coefficients are forced to 1 and ±1 and whatever you typed is ignored.
  5. Read the result matrix in the hero panel. Rows are separated by semicolons, so [6 8; 10 12] means the first row is 6 8 and the second is 10 12.
  6. Use the four secondary figures to check yourself. Rows and Columns confirm the shape did not change. Sum of entries is a one-number checksum — add up the entries of A and of B separately and the same combination of those two totals must reproduce it. Largest magnitude flags a misplaced decimal point faster than reading every entry.
  7. If you needed the matrix product A×B rather than an entry-wise sum, or a power, transpose or inverse, follow the links in the related calculators — none of those operations is available on this page, by design.

The formula.

(αA + βB)ᵢⱼ = α·aᵢⱼ + β·bᵢⱼ

Every mode on this page is a special case of one expression. Given two matrices A = (aᵢⱼ) and B = (bᵢⱼ) with the same dimensions m × n, and two numbers α and β, the linear combination αA + βB is the m × n matrix whose entry in row i and column j is α·aᵢⱼ + β·bᵢⱼ. Setting α = 1 and β = 1 gives addition, cᵢⱼ = aᵢⱼ + bᵢⱼ. Setting α = 1 and β = −1 gives subtraction, cᵢⱼ = aᵢⱼ − bᵢⱼ. Setting β = 0 drops B out entirely and leaves the scalar multiple cᵢⱼ = α·aᵢⱼ, which is the only mode that does not require a second matrix at all. The dimension rule follows from the definition rather than being bolted on: the expression pairs the (i, j) entry of A with the (i, j) entry of B, so if B has no (2, 3) entry and A does, there is nothing to pair and the sum is undefined. The calculator therefore checks both dimensions before computing anything and reports the mismatch with both shapes printed. Rounding is done once and only at the end. Every entry is parsed from the text you typed straight into an arbitrary-precision decimal, multiplied and added exactly, and only then rounded to ten decimal places for display; the same rounded values are what feed the sum and the largest-magnitude figures, so the secondary numbers always agree with the matrix shown above them. Nothing intermediate is rounded, which is why 0.1 + 0.2 comes back as exactly 0.3 and not as 0.30000000000000004. Two properties are worth checking on the calculator itself because they are the ones people misremember. First, entry-wise operations never change the shape: a 2 × 3 plus a 2 × 3 is a 2 × 3, and scaling a 4 × 1 leaves it 4 × 1. The matrix product is the operation that changes shape, and it is not on this page. Second, subtraction is not a primitive — A − B is defined as A + (−1)B, which is why the calculator implements it as the linear combination with β = −1 rather than as a separate code path, and why A − B and B − A differ only in sign.

A worked example.

Example

The general mode, evaluating 2A − 3B for A = [1 2; 3 4] and B = [5 6; 7 8]. Take the coefficients one at a time. Scaling A by α = 2 gives [2 4; 6 8]. Scaling B by β = −3 gives [−15 −18; −21 −24]. Adding those two entry by entry: 2 + (−15) = −13 in the top-left, 4 + (−18) = −14 in the top-right, 6 + (−21) = −15 in the bottom-left, and 8 + (−24) = −16 in the bottom-right. The result output is therefore [-13 -14; -15 -16]. The shape did not change, so rows is 2 and columns is 2 — entry-wise arithmetic can never turn a 2 × 2 into anything else. The sumOfEntries output is −13 − 14 − 15 − 16 = −58, and you can check that against the inputs without recomputing the matrix: the entries of A total 10 and the entries of B total 26, and 2 × 10 − 3 × 26 = 20 − 78 = −58, which is the same figure. The maxAbsEntry output is 16, the largest absolute value among the four entries. Switching the mode to "A + B" with the same two matrices, which is what the calculator shows on first load, gives result = [6 8; 10 12], sumOfEntries = 36 and maxAbsEntry = 12 — because 1 + 5 = 6, 2 + 6 = 8, 3 + 7 = 10 and 4 + 8 = 12.

matrix B5 6 7 8
matrix A1 2 3 4
alpha2
operationcombination
beta-3

Frequently asked questions.

How do you add two matrices?
Add the entries that sit in the same position. If A = [1 2; 3 4] and B = [5 6; 7 8], then A + B = [6 8; 10 12], because 1 + 5 = 6, 2 + 6 = 8, 3 + 7 = 10 and 4 + 8 = 12. The two matrices must have exactly the same number of rows and the same number of columns — there is no way to add a 2 × 3 to a 2 × 2, because two of the positions in the larger matrix would have nothing to pair with. The result always has the same shape as the inputs.
Why does this calculator not multiply two matrices together?
Because the matrix product is a genuinely different operation and it has its own page. Addition, subtraction and scalar multiplication are entry-wise: the (i, j) entry of the answer depends only on the (i, j) entries of the inputs, both matrices must be the same size, and the shape never changes. The product A×B mixes each full row of A with each full column of B, needs only the inner dimensions to agree (m × n times n × p), produces an m × p result whose shape usually differs from both inputs, and is not commutative. Putting both on one page would blur a boundary that matters. Use the matrix multiplication calculator, linked below.
What is a linear combination of matrices?
It is the expression αA + βB, where α and β are numbers: scale A by α, scale B by β, then add the two results entry by entry. It is the single formula that all the other modes are special cases of. α = β = 1 is addition; α = 1, β = −1 is subtraction; β = 0 is a plain scalar multiple. It shows up directly in practice — a gradient-descent update is W − ηG, which is a linear combination with α = 1 and β = −η, and a covariance shrinkage estimator is αS + βT, a weighted blend of a sample matrix and a target.
How do I multiply a matrix by a number?
Multiply every single entry by that number. Encyclopedia of Mathematics puts it as: the product of the matrix A by the scalar α is the matrix αA = (α·aᵢⱼ). So 2 · [1 2; 3 4] = [2 4; 6 8], and −2.5 · [1 2; 3 4] = [-2.5 -5; -7.5 -10]. Choose the "α · A" mode and set α to your number. Matrix B is ignored in that mode, so you can leave it as it is. Scaling never changes the shape and never changes which entries are zero.
In what format should I type a matrix?
One row per line, with the entries in a row separated by spaces or commas. So the 2 × 2 matrix with first row 1 2 and second row 3 4 can be typed as "1 2" on one line and "3 4" on the next. If you would rather keep it on a single line, semicolons also separate rows, so "1,2;3,4" and "1, 2 ; 3, 4" parse identically. Decimals, negative numbers and leading signs are all fine. The limit is 10 rows by 10 columns — past that a textarea is the wrong tool and the result stops being readable.
Is matrix addition commutative and associative?
Yes to both, and that is not true of matrix multiplication. A + B = B + A because ordinary addition of the paired entries is commutative, and (A + B) + C = A + (B + C) for the same reason. Together with the zero matrix acting as an identity, the existence of −A for every A, and the two distributive laws for scalars, these are the axioms that make the m × n matrices a vector space of dimension m·n. Matrix multiplication is associative but is not commutative — AB and BA are usually different and can even have different shapes.
What does the "sum of entries" figure tell me?
It is a checksum. Adding every entry of a matrix is itself a linear operation, so the total for αA + βB must equal α times A's total plus β times B's total. In the worked example, A's entries total 10, B's total 26, and 2 × 10 − 3 × 26 = −58 — exactly the sum of entries the calculator reports for 2A − 3B. If you compute the matrix by hand and your total does not match, one entry is wrong, and you have found that out without checking all of them individually.
Why does 0.1 + 0.2 come out as exactly 0.3 here?
Because the calculator does its arithmetic in arbitrary-precision decimal rather than in binary floating point. In the IEEE-754 double precision used by ordinary JavaScript numbers, 0.1 and 0.2 have no exact binary representation and their sum prints as 0.30000000000000004. Each entry here is parsed from the text you typed straight into a decimal value, all multiplication and addition is exact, and rounding happens once at the very end, to ten decimal places. Nothing intermediate is rounded, so small errors cannot accumulate across a 10 × 10 matrix.
Can I add matrices of different sizes?
No, and the calculator will refuse rather than guess. Entry-wise operations pair the (i, j) entry of one matrix with the (i, j) entry of the other; if one matrix has a position the other does not, there is nothing to pair with and the sum is undefined — not zero, not padded, simply not a defined operation. The error message prints both dimensions, so "is 2×3 but A is 2×2" tells you immediately which matrix you mistyped. The only operation on this page that does not need a second matrix at all is the scalar mode.
What is the zero matrix and the additive inverse?
The zero matrix of a given size is the matrix with every entry 0. It is the additive identity: A + 0 = A for every A of that size. The additive inverse of A is −A, the matrix obtained by negating every entry — which you can produce here with the scalar mode and α = −1. It satisfies A + (−A) = 0. Those two facts, together with commutativity, associativity and the distributive laws for scalars, are why the m × n matrices form a vector space, and they are the reason you are allowed to move terms across an equals sign in a matrix equation exactly as you would with numbers.

References& sources.

  1. [1]NIST Digital Library of Mathematical Functions, §1.3 "Determinants, Linear Operators, and Spectral Expansions", subsection 1.3(iv) "Matrices as Linear Operators" — the reference treatment of matrices acting as linear operators. Retrieved 2026-07-29; open access.
  2. [2]Encyclopedia of Mathematics (EMS Press / Springer), article "Matrix" — gives the definitions used on this page verbatim: A+B = (a_ij+b_ij) and αA = (α a_ij). Living reference work, retrieved 2026-07-29; open access.
  3. [3]Encyclopedia of Mathematics (EMS Press / Springer), article "Matrix multiplication" — distinguishes Cayley multiplication from Hadamard (entry-wise) and Kronecker multiplication, which is why this page keeps the Cayley product on a separate calculator. Retrieved 2026-07-29; open access.
  4. [4]MIT OpenCourseWare 18.06 Linear Algebra, Spring 2010, Prof. Gilbert Strang — full lecture course covering matrix operations, elimination, inverses and determinants. Licensed CC BY-NC-SA 4.0; retrieved 2026-07-29; open access.
  5. [5]Cayley, A. (1858). "A Memoir on the Theory of Matrices." Philosophical Transactions of the Royal Society of London 148, 17–37 — the founding paper of matrix algebra, which defines addition, scalar multiplication and the product. DOI resolves; the publisher returned HTTP 403 to an unauthenticated request, so this citation is bibliographic and gated, not a page that was read in full.
  6. [6]LAPACK Users' Guide, 3rd edition (Anderson et al., SIAM, 1999), §2.3 "Driver Routines" — the reference numerical-linear-algebra library documentation; the standard against which entry-wise versus factorisation-based operations are separated. Retrieved 2026-07-29; open access.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 977 calculators remain free
  • No billing is enabled
Coming soon