How to organize add and multiply matrices Bill Shillito

Translator: Andrea McDonough
Reviewer: Bedirhan Cinar

By now, I’m sure you know

that in just about anything you do in life,

you need numbers.

In particular, though,

some fields don’t just need a few numbers,

they need lots of them.

How do you keep track of all those numbers?

Well, mathematicians dating back

as early as ancient China

came up with a way to represent

arrays of many numbers at once.

Nowadays we call such an array a “matrix,”

and many of them hanging out together, “matrices”.

Matrices are everywhere.

They are all around us,

even now in this very room.

Sorry, let’s get back on track.

Matrices really are everywhere, though.

They are used in business,

economics,

cryptography,

physics,

electronics,

and computer graphics.

One reason matrices are so cool

is that we can pack so much information into them

and then turn a huge series of different problems

into one single problem.

So, to use matrices, we need to learn how they work.

It turns out, you can treat matrices

just like regular numbers.

You can add them,

subtract them,

even multiply them.

You can’t divide them,

but that’s a rabbit hole of its own.

Adding matrices is pretty simple.

All you have to do is add the corresponding entries

in the order they come.

So the first entries get added together,

the second entries,

the third,

all the way down.

Of course, your matrices have to be the same size,

but that’s pretty intuitive anyway.

You can also multiply the whole matrix

by a number, called a scalar.

Just multiply every entry by that number.

But wait, there’s more!

You can actually multiply one matrix by another matrix.

It’s not like adding them, though,

where you do it entry by entry.

It’s more unique

and pretty cool once you get the hang of it.

Here’s how it works.

Let’s say you have two matrices.

Let’s make them both two by two,

meaning two rows by two columns.

Write the first matrix to the left

and the second matrix goes next to it

and translated up a bit,

kind of like we are making a table.

The product we get when we multiply the matrices together

will go right between them.

We’ll also draw some gridlines to help us along.

Now, look at the first row of the first matrix

and the first column of the second matrix.

See how there’s two numbers in each?

Multiply the first number in the row

by the first number in the column:

1 times 2 is 2.

Now do the next ones:

3 times 3 is 9.

Now add them up:

2 plus 9 is 11.

Let’s put that number in the top-left position

so that it matches up with the rows and columns

we used to get it.

See how that works?

You can do the same thing to get the other entries.

-4 plus 0 is -4.

4 plus -3 is 1.

-8 plus 0 is -8.

So, here’s your answer.

Not all that bad, is it?

There’s one catch, though.

Just like with addition,

your matrices have to be the right size.

Look at these two matrices.

2 times 8 is 16.

3 times 4 is 12.

3 times

wait a minute,

there are no more rows in the second matrix.

We ran out of room.

So, these matrices can’t be multiplied.

The number of columns in the first matrix

has to be the same as the number of rows in the second matrix.

As long as you’re careful

to match up your dimensions right, though,

it’s pretty easy.

Understanding matrix multiplication

is just the beginning, by the way.

There’s so much you can do with them.

For example, let’s say you want

to encrypt a secret message.

Let’s say it’s “Math rules”.

Though, why anybody would want to keep this a secret

is beyond me.

Letting numbers stand for letters,

you can put the numbers in a matrix

and then an encryption key in another.

Multiply them together

and you’ve got a new encoded matrix.

The only way to decode the new matrix

and read the message

is to have the key,

that second matrix.

There’s even a branch of mathematics

that uses matrices constantly,

called Linear Algebra.

If you ever get a chance to study Linear Algebra,

do it, it’s pretty awesome.

But just remember,

once you know how to use matrices,

you can do pretty much anything.

译者:Andrea McDonough
审稿人:Bedirhan Cinar

到现在为止,我敢肯定你知道

,在你生活中所做的任何事情中,

你都需要数字。

但特别是,

有些字段不仅需要几个数字,

还需要很多数字。

您如何跟踪所有这些数字?

好吧,

早在中国古代的数学家

就想出了一种方法来一次表示

许多数字的数组。

如今,我们将这样的阵列称为“矩阵”

,其中许多挂在一起的称为“矩阵”。

矩阵无处不在。

他们就在我们周围,

即使现在就在这个房间里。

对不起,让我们回到正轨。

不过,矩阵确实无处不在。

它们用于商业、

经济学、

密码学、

物理学、

电子学

和计算机图形学。

矩阵如此酷的一个原因

是我们可以将如此多的信息打包到它们中

,然后将大量不同的问题

变成一个问题。

因此,要使用矩阵,我们需要了解它们是如何工作的。

事实证明,您可以

像对待常规数字一样对待矩阵。

您可以将它们相加、

相减,

甚至相乘。

你不能把它们分开,

但这本身就是一个兔子洞。

添加矩阵非常简单。

您所要做的就是

按照它们出现的顺序添加相应的条目。

所以第一个条目被加在一起

,第二个条目

,第三个,

一直向下。

当然,您的矩阵必须具有相同的大小,

但无论如何这非常直观。

您还可以将整个矩阵

乘以一个数字,称为标量。

只需将每个条目乘以该数字即可。

但是等等,还有更多!

您实际上可以将一个矩阵乘以另一个矩阵。

但是,这不像添加它们

,您可以逐条添加它们。

一旦你掌握了它,它就会更加独特和非常酷。

这是它的工作原理。

假设您有两个矩阵。

让我们把它们两个两个,

意思是两行两列。

将第一个矩阵写到左边

,第二个矩阵在它旁边并向上

平移一点,

有点像我们正在制作一张表格。

当我们将矩阵相乘时得到的乘积

将正好在它们之间。

我们还将绘制一些网格线来帮助我们。

现在,看看第一个矩阵的第一行

和第二个矩阵的第一列。

看看每个都有两个数字吗?

将行中的第一个数字乘以列中

的第一个数字:

1 乘以 2 是 2。

现在做下一个:

3 乘以 3 是 9。

现在将它们相加:

2 加 9 是 11。

让我们把那个数字放在 左上角的位置,

以便它与我们用来获取它的行和列匹配

看看它是如何工作的?

您可以执行相同的操作来获取其他条目。

-4 加 0 是 -4。

4 加 -3 为 1。

-8 加 0 为 -8。

所以,这就是你的答案。

没那么糟糕,是吗?

不过,有一个问题。

就像加法一样,

你的矩阵必须是正确的大小。

看看这两个矩阵。

2 乘以 8 是

16。3 乘以 4 是 12。3

次等一分钟,

第二个矩阵中没有更多行了。

我们用完了房间。

所以,这些矩阵不能相乘。

第一个矩阵中的列

数必须与第二个矩阵中的行数相同。

不过,只要你小心

地匹配你的尺寸,

这很容易。

顺便说一句,理解矩阵乘法仅仅是个开始。

你可以用它们做很多事情。

例如,假设您

要加密一条秘密消息。

假设它是“数学规则”。

不过,为什么有人要保守这个

秘密,我无法理解。

让数字代表字母,

您可以将数字放在一个矩阵中

,然后将加密密钥放在另一个矩阵中。

将它们相乘

,你就得到了一个新的编码矩阵。

解码新矩阵并读取消息的唯一方法

是拥有密钥,

即第二个矩阵。

甚至还有一个数学分支

经常使用矩阵,

称为线性代数。

如果你有机会学习线性代数,

那就去做吧,这太棒了。

但请记住,

一旦你知道如何使用矩阵,

你几乎可以做任何事情。