8.1 Matrix & Vector Addition

If \(\mathbf{A}\) is a (\(r \times c\)) matrix and \(\mathbf{B}\) is a (\(r \times c\)) matrix (Note: nrow(A) = nrow(B) and ncol(A) = ncol(B)!), then \(\mathbf{A + B}\) is a (\(r \times c\)) matrix with \((i, j)\)th element \[(\mathbf{A + B})_{ij} = a_{ij}+ b_{ij}\]

A = matrix(c(1,2,3,4),nrow=2,ncol=2)
B = matrix(c(5,6,7,8),nrow=2,ncol=2)

A + B #element wise addition

8.1.1 Properties

Here are some useful properties of matrices:

  1. Communtative Property

\[ \mathbf{A}+ \mathbf{B} = \mathbf{B + A}\]

  1. Associative Property

\[ \mathbf{A} + (\mathbf{B} + \mathbf{C}) = (\mathbf{A} + \mathbf{B}) + \mathbf{C}\]

  1. Additive Identity \[\mathbf{A} + \mathbf{0}= \mathbf{A}\] where \(\mathbf{0}\) is a \(r\times c\) matrix with 0 elements.

  2. Additive Inverse

  • For any \(r\times c\) matrix \(\mathbf{A}\), there is a \(r\times c\) matrix \(\mathbf{B}\) (\(= -\mathbf{A}\)) such that \[\mathbf{A} + \mathbf{B}= \mathbf{0}\]