Is a 1×1 matrix a scalar?
By Murray Bourne, 26 Nov 2015
Reader Nour recently wrote:
Hello! 🙂
I just had a problem and got stuck when i tried to multiply (A.B).C where A ,B and C are three matrices with dimensions 1x3, 3x1 and 3x1 respectively. I got the product of (A.B) with a 1x1 dimensional matrix.
The question is: can a 1x1 matrix be a scalar? So should I just stop and say that 1x1 and 3x1 can't be multiplied?
Or is the matrix [2] = 2 a scalar (for example)?
And continue multiplying the scalar (AB) with the matrix C?
This was an interesting question. First, let me explain the issue a bit.
Multiplying matrices
We learn in the Multiplying Matrices section that we can multiply matrices with dimensions (m × n) and (n × p) (say), because the inner 2 numbers are the same (both n). The result will be a vector of dimension (m × p) (these are the outside 2 numbers).
Now, in Nour's example, her matrices A, B and C have dimensions 1x3, 3x1 and 3x1 respectively.
So let's invent some numbers to see what's happening.
Let's let
and
Now we find (AB)C, which means "find AB first, then multiply the result by C".
Next,
The above line is Nour's dilemma. Are we allowed to multiply the above? We have the following situation:
(1 × 1) matrix × (3 × 1) matrix
According to what I said above, since the inside numbers (1 and 3) are different, then we can't multiply the matrices.
However, if we regard a (1 × 1) matrix as a scalar, we can multiply them just fine, and get the following result:
Which is correct?
Software solutions
Scientific Notebook gave me the following for the first step:
That is, it regards a 1×1 matrix as a scalar. It was fine with the scalar times matrix step and gave the same as my second result above.
However, it choked (it refused to answer) when I tried to do it all in one go, like this:
Even giving it a hint (by putting brackets) didn't help:
Wolfram|Alpha regards the result of AB as a (1 × 1) matrix. Here's a screen shot:
It did not behave well and gave rather strange results when trying to do the whole thing. Here's a screen shot of its answer for ABC, where it regarded parts of the question as a vector, and other parts as a matrix:
SageMath (the free cloud-based computer algebra system) also regards the result of AB as a (1 × 1) matrix. It appropriately chokes when trying to do the whole thing. Here's a screen shot:
What do the forums say?
Here's one conversation on Stackexchange: Are one-by-one matrices equivalent to scalars?
This next one has a contradictory conclusion: Is a one by one matrix just a number scalar?
And there's more enlightenment here on this Google+ discussion.
What I told Nour
My feel is that your statement "So i will just stop and say that 1x1 and 3x1 can't be multiplied" is correct. While the outer numbers are the same, the inner ones are not, so you can't multiply them.
What do you think?
Conclusion
Mathematics is not always a consistently behaved beast, despite what many text books say.
See the 10 Comments below.