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
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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
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.
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.
Frequently asked questions.
How do you add two matrices?
Why does this calculator not multiply two matrices together?
What is a linear combination of matrices?
How do I multiply a matrix by a number?
In what format should I type a matrix?
Is matrix addition commutative and associative?
What does the "sum of entries" figure tell me?
Why does 0.1 + 0.2 come out as exactly 0.3 here?
Can I add matrices of different sizes?
What is the zero matrix and the additive inverse?
References& sources.
- [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]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]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]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]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]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