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?

  • $\begingroup$ anyway, you cannot add matrices to scalars unless you define an external operation or at least a specific notation meaning that the scalar is a shortcut to a matrix ( or vice versa ). $\endgroup$
    – user354674
    Aug 19, 2016 at 4:58

5 Answers 5


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.

  • $\begingroup$ It might not be geometrically meaningful, but then again not every matrix is used in geometry. $\endgroup$
    – Erik
    Jul 30, 2015 at 15:23
  • 1
    $\begingroup$ Interpreting $A+b$ as $A+bI$ is the most algebraically clear way: in any $K$-algebra it is reasonable to identify $K$ with the minimal subalgebra containing the identity. +1 $\endgroup$
    – lisyarus
    Jun 15, 2017 at 5:55


$I$ Usually refers to an identity matrix https://en.wikipedia.org/wiki/Identity_matrix


$J$ is less common and usually refers to a matrix of all ones https://en.wikipedia.org/wiki/Matrix_of_ones


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


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}.$

  • $\begingroup$ This doesn't really say anything that the existing answers does not, so adding this to a question that is more than 4 years old seems like a waste of time. $\endgroup$ Nov 5, 2019 at 14:31
  • $\begingroup$ @Henrik, you're probably right about my answer being a wast of time ;-) I just found this question by chance and I missed a clear and correct answer, that covers it all and therefore I tried to fix that. $\endgroup$ Nov 5, 2019 at 15:22

The broadcasting operator . in Julia modifies an operation or a function so that it can be expanded for matrices. For a matrix A and a scalar b, A .+ b is the matrix in which b is added to each element of A. This idea from Julia can be embraced in mathematics by defining a broadcasted binary addition operation .+ for the same purpose.


matrix scalar addition is mathematically not correct. it looks not as you written.

in numpy or matlab:

$a[2x2] + b = a[2x2] + b\cdot I[2x2]$

$ \begin{pmatrix} a_{11} & a_{12}\\ a_{21} & a_{22} \end{pmatrix} + b \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} = \begin{pmatrix} a_{11} + 1 & a_{12}\\ a_{21} & a_{22} +1 \end{pmatrix} $

In [1]: a = np.matrix('1 , 2; 3, 4') + 1

In [2]: a

matrix([[2, 3], [4, 5]])

  • 2
    $\begingroup$ I do not understand what you are trying to say with your answer, nor what you are trying to answer. I looks like you mean that in MATLAB or numpy matrix scalar addition equals addition with the identy matrix times the scalar. However, the result you show with numpy is simly the addition of the scalar to all matrix elements. The same result is obtained in MATLAB, e.g. with A = magic(2), A+1. $\endgroup$
    – Erik
    Aug 19, 2016 at 8:38

I don't think adding a scalar to a matrix has much sense. It might be, however, quite sound to add a column vector: since matrices represent linear transformations, such expression would represent an affine transformation.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .