Can you add a scalar to a matrix?
If I add a scalar to every element of a matrix, e.g. for a $2\times2$ matrix
$$ \begin{pmatrix}a_{11} & a_{12} \\ a_{21} & a_{22}\end{pmatrix} + b \overset{?}{=} \begin{pmatrix}a_{11}+b & a_{12}+b \\ a_{21}+b & a_{22}+b\end{pmatrix},$$
with $b$ a scalar, then what is the correct notation? Matrix addition and subtraction are only defined for matrices of the same size. However, it seems tedious to first multiply $b$ with a matrix of ones to have two same-sized matrices to add:
$$ J_2 = \begin{pmatrix} 1 & 1 \\ 1 & 1\end{pmatrix}.$$
Thus to write:
$$ \begin{pmatrix}a_{11} & a_{12} \\ a_{21} & a_{22}\end{pmatrix} + bJ_2 = \begin{pmatrix}a_{11}+b & a_{12}+b \\ a_{21}+b & a_{22}+b\end{pmatrix}.$$
Do you always write $A+bJ_d$ (with $d$ the dimensions of $A$)? Another notation would be $A+\mathbf{b}$ (bold $b$), implying a matrix of the size of $A$. However, this notation is also used for the multiplication of $b$ with the identity matrix, $bI_d$, which is different and therefore confusing.
Why is the addition of a scalar to a matrix not simply defined like scalar multiplication, i.e. an operation of every matrix element? An example where this is permitted is the MATLAB language, where you can add a scalar to a matrix $A$ simply by addition: e.g. A+3
. I feel this is a logical choice. Addition of a scalar to a matrix could be defined as $A+b = A+bJ_d$, with $d$ the dimensions of $A$. This is commutative and associative, just like regular matrix addition. Then $A+\mathbf{b}$ would be the addition of $A$ and $bI_d$ and $A+B$ the matrix addition as we know it, only valid for matrices of the same dimensions. Why aren't these the definitions?
Solution 1:
It's probably because it's not a geometrically meaningful operation; a linear transformation whose matrix in one basis is all ones, has another matrix in another basis.
Whenever I've seen the notation $A+b$ in mathematics, it has meant $A+bI$ (where $A$ is a quadratic matrix and $I$ is the identity matrix of the same size). Some people write $\det(A-\lambda)$ for the characteristic polynomial, for example.
Solution 2:
Clarification:
$I$ Usually refers to an identity matrix https://en.wikipedia.org/wiki/Identity_matrix
$I=\begin{bmatrix}1&0&\cdots&0\\0&1&\cdots&0\\\vdots&\vdots&\ddots&\vdots\\0&0&\cdots&1\end{bmatrix}$
$J$ is less common and usually refers to a matrix of all ones https://en.wikipedia.org/wiki/Matrix_of_ones
$J=\begin{bmatrix}1&1&\cdots&1\\1&1&\cdots&1\\\vdots&\vdots&\ddots&\vdots\\1&1&\cdots&1\end{bmatrix}$
Does it make sense?
Yes, it absolutely does. One example is the PageRank algorithm https://epubs.siam.org/doi/pdf/10.1137/S0036144503424786 page 152 where they add a scalar to a square matrix like this:
$$\underset{\text{square matrix}}{\underbrace{\bar{P}}}+\underset{\text{scalar}}{\underbrace{(1-\alpha)}}\underset{\begin{array}{c}\text{square matrix}\\\text{of all ones}\end{array}}{\underbrace{ee^T}}$$
Is it correct?
I don't know for sure. I wouldn't use $A+\lambda$ where A is a matrix and $\lambda$ a scalar in a document anyway because I personally think it looks weird and it is more difficult to see how an equation works with the dimensions.
However, it works perfectly fine in Matlab for example:
magic(3) + 1
ans =
9 2 7
4 6 8
5 10 3
Recommendation:
Use either:
- $A+\lambda ee^T$
- $A+\lambda J$
In both cases, you probably need to explain that $e$ ie a column vector of all ones or that $J$ is a matrix of all ones. Implying that $I$ or $J$ has the right dimension should be fine, I personally like neither $I_\text{dim}$ nor $J_\text{dim}.$