# Show that any linear function $f:\mathbb{R}^n\to\mathbb{R}$ is of the form $f(x)=a^Tx$ for some vector $a\in\mathbb{R^n}$.

$$a)$$ Let $$a$$ be a (column) vector in $$\mathbb{R}^n$$.

Show that the function $$f(x)=a^Tx$$ is linear function from $$\mathbb{R}^n$$ to $$\mathbb{R}$$

$$b)$$ Show that any linear function $$f:\mathbb{R}^n\to\mathbb{R}$$ is of the form $$f(x)=a^Tx$$ for some vector $$a\in\mathbb{R^n}$$.

Hint let $$e_i$$ denote the standard unit vectors in $$\mathbb{R}^n$$ and write $$x$$ as $$x=x_1e_1+\dots e_nx_n.$$ Let $$a_i:=f(e_i)\in\mathbb{R}.$$ What is $$f(x_1e_1+\dots+e_nx_n)$$

I proved $$a)$$.

$$a)$$

Proof.

$$\text{WTS } f \text{ is a function s.t. } f:\mathbb{R}^n\to\mathbb{R}\text{ and }f \text{ is linear}$$

First part:

By given info that

$$a:=\begin{pmatrix}a_1\\\vdots\\a_n\end{pmatrix},x:=\underbrace{\begin{pmatrix}x_1\\\vdots\\x_n\end{pmatrix}}_{\text{input}\in\mathbb{R}^n},a^T=\begin{pmatrix}a_1\\\vdots\\a_n\end{pmatrix}^T=\begin{pmatrix}a_1\space\dots\space a_n\end{pmatrix}$$

$$\Rightarrow a^Tx=\begin{pmatrix}a_1\space\dots\space a_n\end{pmatrix}\begin{pmatrix}x_1\\\vdots\\x_n\end{pmatrix}=\underbrace{\sum_{i=1}^na_ix_i}_{\text{output}\in\mathbb{R}}$$

So we indeed have $$\boxed{f:\mathbb{R}^n\to\mathbb{R}}$$

Second part:

To show $$f$$ is linear

Let $$x_1:=\begin{pmatrix}x_{1_1}\\\vdots\\x_{1_n}\end{pmatrix},x_2:=\begin{pmatrix}x_{2_1}\\\vdots\\x_{2_n}\end{pmatrix},x:=cx_1+x_2=\begin{pmatrix}cx_{1_1}+x_{2_1}\\\vdots\\cx_{1_n}+x_{2_n}\end{pmatrix}$$

(To avoid confusion, notice $$x_1,x_2,x$$ are redefined here, which is different from First part)

Just verify that $$f(cx_1+x_2)=cf(x_1)+f(x_2)$$

Have

$$f(cx_1+x_2)=f(x)$$

$$=\sum_{i=1}^na_ix_i=\sum_{i=1}^na_i(cx_{1_i}+x_{2_i})$$

$$=c\sum_{i=1}^na_ix_{1_i}+\sum_{i=1}^na_ix_{2_i}=\boxed{cf(x_{1_i})+f(x_{2_i})}\tag*{\square}$$

$$b)$$

Be honestly I'm not sure I understood what $$b)$$ is asking, here is my attempts

My thoughts

Try to formalize 'any linear function', but what does this term really mean? For example $$f_1(x)=x+1$$ and $$f_2(x)=x+2-1$$, are they the same linear function?

Maybe we use another definition: $$\text{two functions with same domain are different iff they have different range}$$

So the proof should show that each functons with domain $$\mathbb{R}^n$$ that are different can all be written in form of $$a^Tx$$, in another words the range of each different $$f$$ in this form biject to all the possible subsets of $$\mathbb{R}$$.

Start from the hint.

Proof.

Let $$e_1\dots e_n\text{, be all standard basis of }\mathbb{R}^n$$

$$a_i:=f(e_i)\in\mathbb{R} \text{, where } i\in[1,n]\cap\mathbb{Z}$$

That $$f(x)=f(x_1e_1+\dots+e_nx_n)=x_1f(e_1)+\dots +x_nf(e_n)=a_1x_1\dots a_nx_n=a^Tx\tag*{\square}$$

For $$b)$$, suppose $$f:\mathbb{R}^n\to\mathbb{R}$$ is a linear transformation. We need to show that $$f$$ is necessarily in the form $$f(x)=a^tx$$ for some $$a\in\mathbb R^n$$. Since any linear map is determined by what it does to the elements of the basis, we can define $$a_i:=f(e_i)$$ for $$i=1,2,\dots,n$$.
Then, for all $$x=(x_1,x_2,\dots,x_n)\in\mathbb{R}^n$$ note the following \begin{align} f(x) &= f\left( \sum_{i=1}^n x_ie_i \right) = \sum_{i=1}^n x_if(e_i) = \sum_{i=1}^n a_ix_i \\ &= \begin{pmatrix} a_1&a_2&\cdots&a_n \end{pmatrix} \begin{pmatrix} x_1\\x_2\\ \vdots \\ x_n \end{pmatrix} = a^tx. \end{align} here, $$a=(a_1,a_2,\dots,a_n)^t$$, obviously.