# Matrix Addition And Subtraction Calculator

By Maciej Kowalski, PhD candidate
Last updated: Jun 09, 2021

Welcome to the matrix addition and subtraction calculator, where you'll have the chance to learn all about adding and subtracting matrices. As opposed to matrix multiplication, the two basic operations we describe today are just as easy on matrices as they are on regular numbers. We'll start with a basic definition and quickly move on to see how to add matrices. And, if you know how to get the sum, the difference is basically the same thing.

So, sit back, grab your morning/afternoon coffee, and let's begin!

## What is a matrix?

You know all those well-known numbers like `2`, `-16`, or `7½`? These are what we call rational numbers. In essence, this means that they can be described in the form of a fraction of two integers. But it would be boring if mathematics ended there, so the scientists discovered an extension of rational numbers, which they call the real numbers. This new group includes any positive or negative number, like the the square roots of any positive value, or the mysterious `π`.

As the name suggests, real numbers are the real deal. In some sense, they are what describe the world around us, i.e., they appear in all the shapes we see. That's right - even the weird ones accompany us in everyday life: `√2` is what gives us the diagonal of a square, and `π` is present in every circle's circumference.

Again, mathematicians got too bored to stop at that. Just like a dream in that famous movie, they decided to go deeper, and discovered complex numbers and quaternions. We can't see these that easy in the world around us (but believe us, they're there), and calculations with them get a little tricky. Fortunately, they don't interest us here at all.

There is another extension of the real numbers. Think about it, what if instead of a single number... bear with us! What if instead of a single number, we considered a few of them at once? Mind = blown. A matrix is an array of elements (usually numbers) that has a set number of rows and columns. An example of a matrix would be

A =
 ⌈ 3 -1 ⌉ | 0 2 ｜ ⌊ 1 -1 ⌋

Moreover, we say that a matrix has cells or boxes into which we write the elements of our array. For example, matrix `A` above has the value `2` in the cell that is in the second row and the second column.

Matrices are a way to store more data than an individual number. They do it by containing more than one number (unless they are a 1-cell matrix). Clever, huh? They (and their determinant) are useful, especially when dealing with:

But since they contain numbers, and are supposed to be an extension of numbers, can we do the usual operations on matrices the way we do them on regular numbers? Like, if we know how to add regular numbers, does it mean that we know how to add matrices?

Yes and no. All the operations that we know from arithmetics are defined for matrices, but we have to be careful. As mentioned in the beginning, multiplying matrices is a tricky business. Dividing is even worse. Lucky for us, we've met each other on the matrix addition and subtraction calculator, so all we need is adding and subtracting matrices, and that is very easy.

The first thing you need to know when learning about matrices is that you can't always do what you want. With regular numbers, the worst that can ever happen is dividing by zero. Here, however, we have it worse than that.

Adding and subtracting matrices is possible if and only if the matrices are of the same size. For example, recall the matrix `A` from the above section:

A =
 ⌈ 3 -1 ⌉ | 0 2 ｜ ⌊ 1 -1 ⌋

If we have two other matrices:

B =
 ⌈ 1 0 ⌉ ⌊ -1 4 ⌋

and

C =
 ⌈ 4 -4 ⌉ | -2 8 ｜ ⌊ 2 -4 ⌋

then there is no such thing as `A + B` or `A - B`, but `A + C` and `A - C` are perfectly fine.

Now, how do we know how to add matrices? It's just as you might have expected: we do it cell by cell. In general, let us take two matrices of the same size, call them `A` and `B`. Say that their cells are indexed by `aᵢⱼ` and `bᵢⱼ` respectively, where `i` denotes the number of the row, and `j` denotes the number of the column. Then if `A + B` has cells `cᵢⱼ` and `A - B` has cells `dᵢⱼ`, then

`cᵢⱼ = aᵢⱼ + bᵢⱼ` and `dᵢⱼ = aᵢⱼ - bᵢⱼ`.

A piece of cake, wouldn't you say? Also, in particular, observe that `A + B` and `A - B` have the same size as the matrices we started with.

Why don't we make good use of the time we spent reading through all this theory, and see some examples?

## Example: using the matrix addition and subtraction calculator

Suppose that you'd like to keep track of your monthly budget throughout the year. We'll do it with the help of matrices and the matrix addition and subtraction calculator.

Say that you make \$3,000 per month, so, let's put that in each cell of our matrix as the base amount we'll be working with.

base =
 ⌈ \$3,000 \$3,000 \$3,000 ⌉ | \$3,000 \$3,000 \$3,000 ｜ | \$3,000 \$3,000 \$3,000 ｜ ⌊ \$3,000 \$3,000 \$3,000 ⌋

We see that we have a matrix with four rows and three columns, so, if we'd like to use the matrix addition and subtraction calculator, we need to input those dimensions at the top of our tool. This will show us a symbolic picture of the operation we'll be doing. The first matrix in our calculations will be the `base` described above. This means that the \$3,000-values need to be input as the left array's cells. Since its coefficients are `a₁`, `b₁`, `c₁`, `a₂`, and so on, we should put

`a₁ = 3,000`, `a₂ = 3,000`, `a₃ = 3,000`,

`b₁ = 3,000`, `b₂ = 3,000`, `b₃ = 3,000`,

`c₁ = 3,000`, `c₂ = 3,000`, `c₃ = 3,000`,

`d₁ = 3,000`, `d₂ = 3,000`, `d₃ = 3,000`.

Here each cell represents one month, and each row represents a quarter of the year. Suppose that you get an additional \$250 Easter bonus in April (first month of the second quarter) and a \$250 Christmas bonus in December (third month of the fourth quarter). Also, in September (third month of the third quarter), you've earnt a raise netting you \$300 more a month since then. Lastly, you've taken some time off to drink a cold one at the beach between July and August (first and second month of the third quarter), so they've cut a percentage of your salary for those months, by, say, \$400.

Let's try to translate all that information into a new matrix:

changes =
 ⌈ \$0 \$0 \$0 ⌉ | \$250 \$0 \$0 ｜ | -\$400 -\$400 \$300 ｜ ⌊ \$300 \$300 \$550 ⌋

Observe that we have the \$400 cells with a minus since that amount was deducted from the income. Similarly to what we did above, we now input the values as the cells of the second matrix:

`x₁ = 0`, `x₂ = 0`, `x₃ = 0`,

`y₁ = 250`, `y₂ = 0`, `y₃ = 0`,

`z₁ = -400`, `z₂ = -400`, `z₃ = 300`,

`u₁ = 300`, `u₂ = 300`, `u₃ = 550`.

Once we put the last number, the matrix addition and subtraction calculator will spit out the sum of the two arrays, which will be the monthly income. However, now that we know how to add matrices, we can also do that by hand:

 income = base + changes =
=
 ⌈ \$3,000 + \$0 \$3,000 + \$0 \$3,000 + \$0 ⌉ | \$3,000 + \$250 \$3,000 + \$0 \$3,000 + \$0 ｜ | \$3,000 + (-\$400) \$3,000 + (-\$400) \$3,000 + \$300 ｜ ⌊ \$3,000 + \$300 \$3,000 + \$300 \$3,000 + \$550 ⌋
=
=
 ⌈ \$3,000 \$3,000 \$3,000 ⌉ | \$3,250 \$3,000 \$3,000 ｜ | \$2,600 \$2,600 \$3,300 ｜ ⌊ \$3,300 \$3,300 \$3,550 ⌋

Unfortunately, that is only the income. It would be far easier to make our dreams come true if we didn't spend any of that on bills or whatnot, wouldn't you say?

Now let's try to sum up your regular monthly expenses:

This means that we have

`\$750 + \$600 + \$150 + \$700 + \$150 + \$250 = \$2,700`

as a base for how much you spend. If we add to that a \$1,000 vacation that you paid in July, a \$600 car repair in May, and a \$400 Black Friday shopping spree in November, we can make a new matrix:

expenses =
 ⌈ \$2,700 \$2,700 \$2,700 ⌉ | \$2,700 \$2,700 + \$600 \$2,700 ｜ | \$2,700 + \$1,000 \$2,700 \$2,700 ｜ ⌊ \$2,700 \$2,700 + \$400 \$2,700 ⌋
=
 ⌈ \$2,700 \$2,700 \$2,700 ⌉ | \$2,700 \$3,300 \$2,700 ｜ | \$3,700 \$2,700 \$2,700 ｜ ⌊ \$2,700 \$3,100 \$2,700 ⌋

No different signs this time. It's difficult to make any profit when taking care of expenses. Boy, how we wish that wasn't the case.

We're left with nothing else than to calculate the total monthly balance, i.e., the difference between our income and expenses. Remember, however, that if you're using the matrix addition and subtraction calculator for that, you need to change the operation at the top to subtraction. But we know all about adding and subtracting matrices, so we can also do it ourselves:

 budget = income - expenses =
=
 ⌈ \$3,000 - \$2,700 \$3,000 - \$2,700 \$3,000 - \$2,700 ⌉ | \$3,250 - \$2,700 \$3,000 - \$3,300 \$3,000 - \$2,700 ｜ | \$2,600 - \$3,700 \$2,600 - \$2,700 \$3,300 - \$2,700 ｜ ⌊ \$3,300 - \$2,700 \$3,300 - \$3,100 \$3,550 - \$2,700 ⌋
=
=
 ⌈ \$300 \$300 \$300 ⌉ | \$550 -\$300 \$300 ｜ | -\$1,100 -\$100 \$600 ｜ ⌊ \$600 \$200 \$850 ⌋

Well, there are a few minuses, but, thankfully, the savings we made were able to take care of that. Also, the end of the year seemed promising. If we changed the car for a bike from time to time, then we might make use of a cash ISA? Something with a good interest rate, perhaps?

Maciej Kowalski, PhD candidate
Operation Matrix size
Number of rows
2
Number of columns
2
First matrix entries
a₁
a₂
b₁
b₂
Second matrix entries
x₁
x₂
y₁
y₂
 ⌈ ⌉ + ⌈ ⌉ = ⌈ ⌉ ⌊ ⌋ ⌊ ⌋ ⌊ ⌋
People also viewed…

### Isosceles Triangle

This isosceles triangle calculator can help in your geometry problems, finding area, height, angles, perimeter or many other parameters. Give it a try!

### Null space

The null space calculator will quickly compute the dimension and basis of the null space of a given matrix of size up to 4x4.

### Sleep

The sleep calculator can help you determine when you should go to bed to wake up happy and refreshed.

### Snowman

The perfect snowman calculator uses math & science rules to help you design the snowman of your dreams! 