Advanced maths

Matrix addition subtraction and scalar multiplication calculator

Add or subtract matching matrices, or multiply every entry of one matrix by an exact scalar.

Your numbers

One row per line or semicolon; separate entries with spaces or commas. Up to 6 rows and 6 columns. Use integers, decimals (up to 6 places) or fractions such as -2/3.
One row per line or semicolon; separate entries with spaces or commas. Up to 6 rows and 6 columns. Use integers, decimals (up to 6 places) or fractions such as -2/3.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Try it, understand it

Explore the result

Choose matching-entry addition/subtraction or a scalar acting on one matrix.

Worked example comparison
ExampleOutputWhat to notice
Add two matching matricesResult dimensions2 × 2The default sum is [6 8; 10 12].
Multiply by zeroResult dimensions2 × 2A zero scalar produces a zero matrix with the same shape.
Use an exact fractional scalarResult dimensions2 × 2One half multiplies every entry of Matrix A.

Check your understanding

Does scalar mode need Matrix B?

No. Only Matrix A and k are used.

Can two differently shaped matrices be added entrywise?

No. Both row and column counts must match.

Behind the numbers

How this calculation works

Each entry is paired with the number in the same row and column of the other matrix. Both matrices must have the same dimensions. The tool preserves rational arithmetic and shows the first pair as a worked step. In scalar mode, multiply each entry of Matrix A by k; Matrix B is ignored. A zero scalar produces a zero matrix with the same dimensions, and a negative scalar reverses every entry’s sign.

THE FORMULACᵢⱼ = Aᵢⱼ + Bᵢⱼ, or Aᵢⱼ − Bᵢⱼ; scalar mode: Cᵢⱼ = kAᵢⱼ

A worked example

Adding A = [1 2; 3 4] and B = [5 6; 7 8] gives [6 8; 10 12]. Both inputs and the result are 2 × 2.

Good to know

For small matrices of exact rational numbers, up to 6 rows and 6 columns. Entries are limited to ±1,000,000; integer fraction denominators to 1,000,000. Decimal input allows up to 6 places. No expressions, scientific notation, complex numbers or uncertain measurements. Large intermediate fractions are bounded to keep the tool responsive.

Matching positions need matching meanings

Imagine a shop records quantities for two products at three branches. One row per branch and one column per product creates a 3 × 2 matrix. Adding a second day’s matrix gives combined quantities only if both days use the same branch and product order.

The calculator can verify dimensions; it cannot verify labels or units you left out. If one matrix lists kilograms and another lists grams, convert the units first. If the second matrix reverses the product columns, reorder them before adding.

Subtraction keeps the order you choose

A − B describes a change relative to B, while B − A reverses every difference. For stock records, choose a consistent convention such as closing quantity minus opening quantity. A negative entry can then describe a decrease rather than an input error.

Addition works entry by entry and is different from matrix multiplication. The product combines rows with columns and may be defined for matrices that cannot be added. Choose the operation that matches the question, not merely the shape of the data.

A quick independent check

After calculating a sum C = A + B, subtract B from C. You should recover A exactly for the accepted rational inputs. Try an entry with a fraction, such as 1/3 + 1/6 = 1/2, to see why an exact fraction can be clearer than a rounded decimal.

If you want to compare changes as percentages, a matrix difference alone is insufficient. Each position needs its own baseline, and a zero baseline makes a relative percentage undefined. Keep that question separate from the absolute change shown here.

A scalar acts on every entry of one matrix

Select scalar mode to multiply Matrix A by one bounded exact rational number. Matrix B is ignored in that mode. A scalar of zero gives the zero matrix with the original dimensions; a scalar of −1 reverses every entry sign. This is not row-by-column matrix multiplication.

The matrix transpose calculator rearranges positions rather than multiplying entries. Matrix addition and subtraction still require two matching shapes; scalar multiplication needs just one matrix and never changes its row or column count.

A few questions, answered

Can I add rectangular matrices?

Yes. Rectangular matrices work when both have exactly the same dimensions, within the 6 × 6 limit.

Why did a zero row disappear from my input?

The calculator does not remove zero rows. Enter each zero explicitly and keep the same number of entries in every row. An empty row is rejected.

Can I paste a spreadsheet range?

Yes. Tabs and spaces separate entries, and new lines separate rows. Paste only the numbers; headings and thousands separators such as 1,000 are not interpreted as labels or grouped numbers.

Find your calculator

Start typing to explore the library.