5

Should we always regard a $1\times 1$ matrix as a scalar? (I think, "yes".) And if so, how should we address this in our elementaty Linear Algebra courses? Let me give an example to illustrate my question.

Suppose $A= \left[\begin{array}{rr}1 & 2 \\-2 & 1\end{array}\right],$ $B = \bigl[-2\,,2\bigr],$ and and $C = \left[\begin{array}{r}4 \\5\end{array}\right].$ Then the calculation \begin{equation} A(BC) = \left[\begin{array}{rr}1 & 2 \\-2 & 1\end{array}\right] \left(\begin{array}{r} \bigl[-2\,,2\bigr] \\ \rule{1pt}{0pt} \end{array}\left[\begin{array}{r}4 \\5\end{array}\right] \right) = \left[\begin{array}{rr}1 & 2 \\-2 & 1\end{array}\right]\cdot 2 = \left[\begin{array}{rr}2 & 4 \\-4 & 2\end{array}\right] \end{equation} seems completely reasonable, doesn't it? And yet it's technically incorrect, since $A$ is a $2\times 2$ matrix and $BC$ is a $1\times 1$ matrix.

I've ben trying to come up with a technically correct way to conclude that $A(BC)$ can indeed by computed as above. And here's the best I can come up with. There's an obvious bijection, let's call it $J$, from the the $1\times 1$ matrices to the scalars, with $x = J([x])$ for any scalar $x$. If we want to be able to carry out ``$A(BC)$'' as above, what we really mean is that it is equal to $AJ\bigl([BC]).$

But someone could ask how we know when it's appropriate to interpret $A(BC)$ as $2A$ and when it's appropriate to interpret that product as undefined. My own answer is that it depends on context or something, but that seems unsatifying to me.

Does anyone know of a good way to address this matter, which is both rigorous at the foundational level and can easily be inserted into an elementary discussion? For example, when we define multiplication of two matrices, should we add a caveat that any $1\times 1$ matrix should be be regard as a scalar? But then, is there ever a situation where we want to regard a $1\times 1$ matrix as just that, and calling it scalar would mess something else up at the level of foundations/definition?

Thanks in advance. -JGW

Eilif
  • 411
Gordon
  • 51
  • 2
  • 1
    https://math.stackexchange.com/questions/1256496/can-a-constant-be-considered-as-1x1-matrix – lafinur Jun 07 '22 at 01:09
  • 3
    $A(BC)$ is simply undefined in this case. The dimensions are not compatible for matrix multiplication. – littleO Jun 07 '22 at 01:11
  • Even if you interpret $BC$ as a scalar, $A(BC)$ would evaluate to $A2$ which doesn't make sense (at least, not to me). But if $A$ were an $n\times 1$ matrix then multiplying $A(BC)$ would be perfectly OK (provided that you interpret $BC$ as a matrix and not a scalar). – David K Jun 07 '22 at 01:15
  • 1
    The thing that you say is completely reasonable is to multiply each element of the matrix with a scalar value got from multiplying $B$ and $C$ together. I don't think that is "reasonable" in any sense that writing $A(BC)$ it's a "reasonable" assumption that scalar multiplication is meant. It's not clear at all what problem you're trying to solve. – Suzu Hirose Jun 07 '22 at 01:17
  • Commentary: What does it mean to say that a $1 \times 1$ matrix can be "regarded" as a scalar? I confess I am often confused by such statements. It is actually not true that a $1 \times 1$ matrix $\begin{bmatrix} x \end{bmatrix}$ is the same thing as the scalar $x$, and I can't make my brain forget that these two things are not the same object. Here is my interpretation of such a statement: if $x$ is a scalar, we will sometimes abuse notation by referring to the $1 \times 1$ matrix $\begin{bmatrix} x \end{bmatrix}$ simply as $x$. So the same symbol $x$ is being used for two different objects. – littleO Jun 07 '22 at 01:20
  • 2
    Isn't my example, where I compute "A(BC) = [2,4; -4,2]," as reasonable as writing things like "1/(1+u^TAv)", when u and v are vectors and A is a matrix? The latter seems reasobable to me because u^tAv "is a scalar", or so we say.

    If we refrain from this sort of usage, then for example how would we present and prove the Sherman Morrison formula?

    – Gordon Jun 07 '22 at 01:54
  • Hmm, when you write $A(BC)$, the operation that you are using is not written explicitly, and it seems implicit that the operation being used when multiplying $A$ by $BC$ is matrix multiplication (which is not valid). When multiplying a matrix by a scalar, the scalar is usually written on the left, so perhaps $(BC) \cdot A$ would be a more clear way to write this. If it genuinely simplified your notation to interpret $A(BC)$ as $(BC) \cdot A$ then you could try it, perhaps followed by a clarifying remark to make sure the meaning is clear. But, I doubt this notation is ever actually useful. – littleO Jun 07 '22 at 03:53
  • 1
    Matrix multiplication is supposed to be associative. How would you interpret $(AB)C$ ? – mr_e_man Jun 07 '22 at 21:21
  • Instead of $1/(1+u^TAv)$ you could write $([1]+u^TAv)^{-1}$ (which is a $1\times1$ matrix) or $1/(1+\text{tr}(u^TAv))$ or $1/(1+\det(u^TAv))$ (both of which are scalars). – mr_e_man Jun 07 '22 at 21:24

4 Answers4

7

While we represent both multiplication of a matrix by a scalar and multiplication of two matrices by juxtaposition of their multiplicands, they are actually different types of multiplication with different definitions (except in some special cases). In my opinion, the difficulties highlighted in your question are caused by conflating these two different types of multiplication, rather than conflating scalars with $1\times1$ matrices.

To illustrate, let's use different symbols for the two types of multiplication, $*\ $ for multiplication of a matrix by a scalar, and $\ \circ\ $ for multiplication of two matrices. The product $\ A*B\ $ is well-defined if and only if one or both of $\ A\ $ and $\ B\ $ are scalars (or $1\times1$ matrices) and the other is a matrix of any dimensions whatever. The matrix product $\ A\circ B\ $, on the other hand, is well-defined whenever the number of columns in the matrix $\ A\ $ is the same as the number of rows in $\ B\ $.

If $\ A\ $ is a scalar (or a $1\times1$ matrix) and $\ B\ $ a row vector, or $\ B\ $ is a scalar (or a $1\times1$ matrix) and $\ A\ $ a column vector, then both $\ A*B\ $ and $\ A\circ B\ $ are well-defined and they are equal. These are the only cases where both $\ A*B\ $ and $\ A\circ B\ $ are well-defined.

In your example, if you take $\ A(BC)\ $ to represent the product $\ A*(B\circ C)\ $, then it is well-defined and you can evaluate it exactly as you have done in your question. Neither of the matrix products $\ A\circ(B\circ C)\ $ or $\ A\circ[2]\ $, however, is well-defined because the multiplicands have incompatible sizes.

lonza leggiera
  • 28,646
  • 2
  • 12
  • 33
  • This is a good, straightforward answer that cuts to the heart of the matter: We're talking about two diferent types of "multiplication" and out notation blurs the distinction in this case. Thank you. – Gordon Jun 10 '23 at 14:03
0

Hint: I don't think it's appropriate to mix up the concept of matrices and scalars.

In linear algebra we have the fundamental relationship beween matrices and linear transformations. Multiplication of matrices and composition of linear transformations go hand in hand.

P. R. Halmos writes in Finite-Dimenstional Vector Spaces:

  • Section 38: The relation between transformations and matrices is exactly the same as the relation between vectors and their coordinates, ...
Markus Scheuer
  • 108,315
0

I would wager that your $BC$ is "really" an inner product of vectors, which (by convention) is a scalar. And then you're scalar-multiplying $A$ by that scalar.

So, no compulsion to think that a one-by-one matrix is identified with the corresponding scalar.

Some clarity may be achieved by writing such linear algebra stuff without reference to any choice of basis (hence, not matrices, but linear maps and vectors...) If it becomes impossible to express the issue in such terms, it strongly suggests that there was a "type error" in the original matrix version of the question.

On another hand, there are some identities among matrix expressions of different sizes, e.g., for row vector $v$, $vv^\top=\mathrm{tr}\,v^\top v$. Such things enter in fancier identities such as mentions in the questioner's comment. But these do avoid "type errors", and have intrinsic expressions.

While we're here, we can debunk the somewhat-popular notion that "trace" of a square matrix has no intrinsic expression: first, for a finite-dimensional $k$-vectorspace $V$, the map $V\otimes V^*\to \mathrm{End}_k(V)$ by $(v\otimes\lambda)(w)=\lambda(w)\,v$ is an isomorphism. Then characterize trace by $\mathrm{tr}(v\otimes \lambda)=\lambda(v)$. :)

paul garrett
  • 52,465
-1

Matrices are different mathematical objects than scalars. There is a set of formal properties that must hold for them to be considered matrices.

A $1\times 1$ matrix made of a single element $x \in \mathbb{R}$ could be considered to be a scalar if and only if all properties that hold for the scalar $x$ hold for the $ 1 \times 1$ matrix made of $x$ without contradicting the properties of matrices and scalars.

Let $\begin{bmatrix} x\end{bmatrix}$ be the $1 \times 1$ matrix made of $x$. Assume $\begin{bmatrix} x\end{bmatrix} = x$. Then $\begin{bmatrix} x\end{bmatrix} + \begin{bmatrix} x\end{bmatrix} = x + x = 2x$, which is a real number. But matrix addition is defined as a closed operation; i.e., by definition the sum of matrices must return a matrix. Therefore the result contradicts the properties of matrices.

In conclusion, it is formally incorrect to treat a $1 \times 1$ matrix as a vector. I do not know if this is done in practice. However, I do not see why it should be done. Formal definitions serve a purpose, and not everything that seems intuitive must (or can) be.

lafinur
  • 3,322
  • Then what do we make of expressions sich as "1/(1+u^TAu)". where u and v are vectors and A is a square matrix? This sort of thing shows up for example in the presentation and proof of the Sherman Morrison formula. – Gordon Jun 07 '22 at 02:33
  • In the expression $1+\textbf{u}^\top \textbf{T}\textbf{u}$, the term $\textbf{u}^\top \textbf{T}\textbf{u}$ is a vector, not a matrix. So we are talking something different now. In some contexts, adding a scalar to a vector is a defined operation (e.g., see https://en.wikipedia.org/wiki/Quaternion). Though this are very restricted cotexts and in general adding a scalar to a vector makes no sense. Unless the authors clarify a special meaning of such operation before using it, of course. I do not know if that is the case in the proof of the Sherman Morrison formula. – lafinur Jun 07 '22 at 03:02
  • 1
    @lafinur while not formally correct, MATLAB will happily accept a $1\times 1$ matrix as a scalar. In fact, I suspect that's how it defines a scalar internally, given that when asked to report the dimensions of a scalar it returns [1,1]. Also, the sum of a scalar and a matrix is defined as $a\boldsymbol{1} + \boldsymbol{A}$, where $a$ is a scalar, $\boldsymbol{A}$ is a $n \times m$ matrix and $\boldsymbol{1}$ is a matrix of 1s with compatible dimensions – Victor Souza Jun 07 '22 at 05:01
  • @lafinur on the other hand, in Maxima, scalars and $1 \times 1$ matrices are properly treated as different objects. – Victor Souza Jun 07 '22 at 05:09
  • I understand that, and other programming languages are also flexible when it comes to such things. In R, for example, $\textbf{A}^{-1}$ is not the inverse of a matrix, but a matrix containing the inverse of each element in $A$. This is different to what we mean by $\textbf{A}^{-1}$ in mathematics. My point being programming languages are really not a criteria to stablish if expressions are formally correct in mathematics. They are full of shortcuts and focus on practicality more than in formal consistency. – lafinur Jun 07 '22 at 13:41
  • If $\mathbf{u}$ is a column vector of length $n$ and $T$ is an $n\times n$ matrix, then is "$\mathbf{u}^TT\mathbf{u}$" a matrix or a scalar?

    If it's a matrix then what do we make of expressions like "$1+\mathbf{u}^TT\mathbf{u}$" or $1/(1+\mathbf{u}^TT\mathbf{u})$" which are used all the time?

    – Gordon Jun 10 '23 at 13:54