# Subtract matrix from scalar

Is this even possible? Since you can subtract on the right-hand side I think there must be a way to do it from left-hand side too.

I would like to calculate this:

3 - [2 1] = ??

-
What about $[1,2]$? – Fabian Aug 9 '12 at 11:50
So I assume I should do [(x1-S)*(-1) (x2-S)*(-1)]? – Primož Kralj Aug 9 '12 at 11:55
By definition, you can only add/subtract matrices of the same dimension. – Daryl Aug 9 '12 at 12:08
While Daryl is right, some programming languages may allow you to do something like 3 - [2, 1]. They do this by converting scalar to appropriate size matrix. So 3 - [2, 1] is same converted to [3, 3] - [2, 1] which gives [1, 2] as the final result (as suggested by Fabian). – mythealias Aug 9 '12 at 12:23
I need this in C language and I have this case. I've double checked everything and it comes down to this equation. So you are saying that if I got this equation there must be something else wrong in my algorithm? – Primož Kralj Aug 9 '12 at 12:57

You can't actually add a scalar and a matrix. In general, you can't add two matrices unless they are of the same dimension. However, it is often the case that we denote a scalar matrix (a diagonal matrix all of whose entries are the same) by a scalar. For example, you might write $4$ to denote the matrix $\begin{bmatrix}4 & 0 \\ 0 & 4\end{bmatrix}$. The dimension of the matrix has to be understood from context. This notation allows one to write, for example, $$4-\begin{bmatrix}1 & 2 \\ 3 & 4\end{bmatrix}=\begin{bmatrix}4 & 0 \\ 0 & 4\end{bmatrix}-\begin{bmatrix}1 & 2 \\ 3 & 4\end{bmatrix}=\begin{bmatrix}3 & -2 \\ -3 & 0\end{bmatrix}$$ In your case, however, I have never seen a scalar used to denote a non-square matrix.

-
So you say my case is uncalculable - or is Fabian right? – Primož Kralj Aug 9 '12 at 12:55
I guess you could always define notation such that by $3$ you mean $[3,3]$, in which case Fabian is correct, but I don't think many people would do this. In this case, the expression $3-[1,2]$ just doesn't make sense. – Jonathan Gleason Aug 9 '12 at 13:35
Just to clarify: I did not state that the expression is usually interpreted as [1,2]. In fact, most people would say it is undefined. However, if you really want to give it a meaning [1,2] is the only way I could possibly do so. – Fabian Aug 9 '12 at 15:25
Please explain - is Fabian's way mathematically correct? Or you can't do substraction this way like you can't divide a number with zero? – Primož Kralj Aug 9 '12 at 17:12
For all intents and purposes, $3-[1,2]$ is not defined. – Jonathan Gleason Aug 9 '12 at 22:11

The previous answers that basically say "No, addition/subtraction is not defined between matrices of different dimensions" are the correct answer to your question.

Actually though, something like this is done formally in Clifford algebras. There are elements of the algebra identified with scalars, elements identified as vectors, (and even more elements with different identifications). Because they all live in an algebra, addition, subtraction and multiplication are defined between all of them.

However, this last item is probably not the answer you're looking for, because the addition is just formal: a scalar $\lambda$ plus a vector $v$ is just "$\lambda +v$", and there isn't a formula which presents it as another scalar, or another vector.

-