In this post, we introduce general definition of vector spaces and the linear maps between them. In the post on the finite-dimensional real vectors, we discussed their addition and subtraction, multiple of vectors by numbers, their linear combination, their independence, their dot product, their length and distance, and the angle between them.

### Real vector spaces

First, we define real vector spaces. The nonempty set \(V\) is a real vector space, if there is a binary operation called addition (or sum) on \(V\) and a scalar multiplication from \(\mathbb{R} \times V\) into \(V\) with the following properties:

- The set \(V\) together with addition, denoted by \(+\) is an Abelian group, i.e. the following rules hold for all \(u\), \(v\), and \(w\) in \(V\):
- \((u+v)+w = u+(v+w)\),
- \(u + \vec{0} = \vec{0} + u = u\),
- \(u + (-u) = -u + u = \vec{0}\),
- \(u+v = v+u\).

- The following rules hold for the scalar multiplication for all \(u\) and \(v\) in \(V\) and all real numbers \(r\) and \(s\):
- \(r(u+v) = ru + rv\),

- \((r+s) u = ru + su\),
- \(r(su) = (rs)u\),
- \(1u = u\).

**Example**. The set \(V = \mathbb{R}^n\) with the addition and scalar multiplication, defined in the post on the finite-dimensional real vectors, is a general example for a real vector space.

Let \(V\) be a vector space and \(u_i\)s be arbitrary elements of \(V\). A linear combination of the vectors \(u_i\)s is any vector of the following form: $$r_1 u_1 + \dots + r_n u_n,$$ where \(r_i\)s are real numbers.

### Subspaces of vector spaces

Let \(V\) be a real vector space and \(U\) a nonempty subset of \(V\). By definition, \(U\) is a subspace of the real vector space \(V\) if \(U\) together with the addition of vectors and the scalar multiplication defined for \(V\) is a real vector space.

It is straightforward to prove the following statement:

**Exercise**. Show that the following set if a subspace of \(\mathbb{R}^3\): $$\{(x,y,z): x+y+z = 0\}.$$

**Exercise**. Prove that if \(W_1\) and \(W_2\) are subspaces of a real vector space \(V\), then their intersection \(W_1 \cap W_2\) is also a subspace of \(V\).

### Linear maps in vector spaces

In the post on linear functions, we had a detailed discussion on linear maps from \(\mathbb{R}^2\) into \(\mathbb{R}\). Here, we introduce general linear maps over arbitrary real vector spaces.

Let \(V\) and \(W\) be real vector spaces. By definition, a function \(f\) from \(V\) into \(W\) is a linear map, also known as a linear function, if $$f(ru+sv) = rf(u) + sf(v),$$ for all \(u\) and \(v\) in \(V\) and all real numbers \(r\) and \(s\).

If \(U\), \(V\), and \(W\) are real vector spaces and \(f\) is a linear map from \(U\) into \(V\) and \(g\) is a linear map from \(V\) into \(W\), then it is easy to see that \(g \circ f\), i.e. the composition of \(g\) with \(f\), is a linear map from \(U\) into \(W\).

**Example**. Let \(f: \mathbb{R}^2\) into \(\mathbb{R}^2\) be a function. The reader may check the correctness of the following statements:

- If \(f(x,y) = (x,0)\), then \(f\) is a linear map.
- If \(g(x,y) = (0,y)\), then \(g\) is a linear map.
- If \(h(x,y) = (x+y,x-y)\), then \(h\) is a linear map.
- The function \(\gamma\) defined by $$\gamma(x,y) = $$ $$\left(\sqrt[3]{x^3+y^3},\sqrt[5]{x^5+y^5}\right)$$ is not linear.

**Exercise**. Show that a function \(f\) from \(\mathbb{R}^n\) into \(\mathbb{R}\) is a linear function if and only if there are \(n\) real numbers \(c_i\)s such that $$f(x_1, \dots, x_n) = $$ $$c_1x_1 + \dots + c_nx_n.$$

**Exercise**. Prove that the transpose function from \(M_{p \times q}(\mathbb{R})\) into \(M_{q \times p}(\mathbb{R})\) is a one-to-one and onto linear map. For the definition of the transpose of a matrix, see the post on the matrix operations.

### Matrix representation of linear maps

One may consider a function \(f\) from \(\mathbb{R}^2\) into \(\mathbb{R}^2\), defined by $$f(x,y) = (f_1(x,y), f_2(x,y))$$ as a function from the vector space \(V\) into the vector space \(V\) which takes a vector \(v\) in \(V\) as input and gives a unique vector \(f(u)\) in \(V\) as output.

It is easy to see that $$L : \mathbb{R}^2 \rightarrow \mathbb{R}^2$$ is a linear function if and only if there are four real numbers \(a\), \(b\), \(c\), and \(d\) such that $$L(x,y) = (ax+by, cx+dy).$$

It is sometimes more convenient to consider a vector \((x,y)\) as a column vector of the following form: $$\begin{pmatrix}

x\\

y

\end{pmatrix}.$$ Then, we have $$L\begin{pmatrix}

x\\

y

\end{pmatrix} = \begin{pmatrix}

ax+by\\

cx+dy

\end{pmatrix}.$$ Since the definition of the linear map \(L\) only depends on the real constants \(a\), \(b\), \(c\), and \(d\), we may write $$L(u) = Au,$$ where \(u = (x,y)\) and $$ A =\begin{pmatrix}

a & b\\

c & d

\end{pmatrix} .$$ An object of the form $$ \begin{pmatrix}

a & b\\

c & d

\end{pmatrix} $$ is, by definition, a matrix and $$L(u) = Au$$ is a matrix representation of the linear map \(L\).

**Example**. The matrix representation of the linear map $$f(x,y) = (x,-y)$$ is $$ A =\begin{pmatrix}

1 & 0\\

0 & -1

\end{pmatrix} .$$

**Remark**. In general, one can see that if \(f\) is a linear map from the vector space \(\mathbb{R}^q\) into the vector space \(\mathbb{R}^p\), then its matrix is of the following form:$$ A = \begin{pmatrix} a_{11} & a_{12} & \cdots & a_{1q}\\ a_{21} & a_{22} & \cdots & a_{2q}\\ \vdots & \vdots & \ddots & \vdots\\ a_{p1} & a_{p2} & \cdots & a_{pq} \end{pmatrix}.$$ By definition, it is said that \(A\), which is a \(p \times q\) matrix, is the matrix of the linear map \(f\). We sometimes show the matrix \(A\) by \((a_{ij})\).

#### How to obtain the matrix of a linear map

The proof of the following result is left to the reader:

**Result**. Let \(e_i\)s be the standard basis for \(\mathbb{R}^n\) and \(f : \mathbb{R}^n \rightarrow \mathbb{R}^m\) be a linear map. Then, the matrix of \(f\) is the following \(m \times n\) matrix $$A = \begin{pmatrix} f(e_1) & \cdots & f(e_n) \end{pmatrix},$$ where one can obtain the \(i\)th column of the matrix \(A\) from the value of \(f\) at \(e_i\), for each \(i\).

#### Addition and multiple of matrices

If \(f\) and \(g\) are linear maps from the vector space \(\mathbb{R}^q\) into the vector space \(\mathbb{R}^p\), then their addition, defined by $$(f+g)(u) = f(u)+g(u)$$ is also a linear map from \(\mathbb{R}^q\) into \(\mathbb{R}^p\). Considering the matrices of the linear maps \(f\), \(g\), and \(f+g\) hints that why the addition of matrices is done component-by-component.

Also, observe that if \(r\) is a real number, then multiple of the function \(f\) by the real number \(r\), denoted by \(rf\) and defined by $$(rf)(u) = r(f(u)),$$ is also a linear map from \(\mathbb{R}^q\) into \(\mathbb{R}^p\). Again, considering the matrices of the linear maps \(f\) and \(rf\) hints that why the definition of the multiple of a matrix \((a_{ij})\) by the real number \(r\) is the following matrix $$(ra_{ij}).$$

#### Multiplication of matrices

Finally, if \(f\) is linear map from the vector space \(\mathbb{R}^r\) into the vector space \(\mathbb{R}^q\), and \(g\) is linear map from the vector space \(\mathbb{R}^q\) into the vector space \(\mathbb{R}^p\), then \(g\circ f\) is a linear map from \(\mathbb{R}^r\) into \(\mathbb{R}^p\). Comparison of the matrices of the linear maps \(f\), \(g\), and \(g \circ f\) (of course, it needs some thoughts and works) shows why the (mysterious definition of) multiplication of matrices is as follows:

Let \(A\) be a \(p \times q\) matrix and \(B\) a \(q \times r\) matrix. Then, their multiplication \(C = (c_{ij})\) is a \(p \times r\) matrix and each \(c_{ij}\) is as follows: $$c_{ij} = \sum_{k=1}^{q} a_{ik} b_{kj}.$$

**Remark**. Note that the matrix multiplication \(AB\) is definable if and only if the number of columns in \(A\) is equal to the number of rows in \(B\).

### Kernel of linear maps

If \(f: V \rightarrow W\) is a linear map, then the following set, denoted by \(\ker(f)\), $$ \ker(f) = \{ u\in V : f(u) = \vec{0}\}$$ is the kernel of the map \(f\). In other words, the kernel of \(f\) is the image inverse of the singleton \(\{0\}\), i.e. \(f^{-1}\{0\}\).

The very essential fact related to the kernel of a linear map:

The proof goes as follows:

Let \(u_1\) and \(u_2\) be vectors in \(\ker(f)\) and \(r_1\) and \(r_2\) be real numbers. In order to show that \(\ker(f)\) is a subspace of \(V\), we need to show that $$r_1 u_1 + r_2 u_2 \in \ker(f).$$ For doing so, we need to calculate $$f(r_1 u_1 + r_2 u_2).$$ Observe that $$f(r_1 u_1 + r_2 u_2) = $$ $$r_1 f(u_1) + r_2 f(u_2) = $$ $$r_1 \vec{0} + r_2 \vec{0} = \vec{0}.$$

#### Application of the kernel of a linear map in the theory of differential equations

Let \(a\), \(b\), and \(c\) be real numbers and \(f\) be a twice differentiable function, i.e. \(f^{\prime\prime}\) exists. Let the value of a function \(L\) be as follows: $$L(f) = af^{\prime\prime} + b f^{\prime} + cf.$$ Using basic properties of the derivation operator in single variable calculus, it is easy to see that \(L\) is a linear map and its kernel is the set of all functions satisfying the following differential equation: $$af^{\prime\prime} + b f^{\prime} + cf = 0.$$ Since \(\ker(f)\) is a subspace, we can say that if \(f\) and \(g\) satisfy the mentioned differential equation, then any linear combination \(af+bg\) of the functions \(f\) and \(g\) also satisfies the equation.

**Exercise**. Define \(f: \mathbb{R}^3 \rightarrow \mathbb{R}^2\) by $$f(x,y,z) = (x+y, y+z).$$

- Show that \(f\) is a linear map and find its matrix.
- Evaluate the kernel of \(f\).

**Exercise**. The trace of a real square matrix \(A\), denoted by \(tr(A)\), is the sum of the arrays on the main diagonal of the matrix \(A\). In other words, if \(A = (a_{ij})\), then $$tr(A) = \sum_{i=1}^{n} a_{ii}.$$ Prove that \(tr\) is a linear map from \(M_{n \times n}(\mathbb{R})\) onto \(\mathbb{R}\) with the following additional property: $$tr(AB) = tr(BA).$$