why any vector can be wriiten as the sum of two components in the row space and nullspace? My textbook says that:
there is a $m\times n$ matrix A, any vector x in $R^n$ can be written as the sum of a component $x_r$, in the
row space, and a component $x_n$ in the nullspace:
$$x=x_r+x_n$$
how does it happen?
 A: This a straight-forward consequence of row space and nullspace being perpendicular to each other with their dimensions summing to the entire space.
The intuition is that you take any $\vec{x} \in \mathbb{R}^n$ and project it onto the row space of $A$ to get $x_r$. Then, $x_r \perp (\vec{x} - \vec{x}_r)$ by definition of projection and so $\vec{x} - \vec{x}_r$ is in the null space of $A$.
A: The key fact here every subspace $S \subset\mathbb{R}^n$ has an orthogonal complement $S^\bot$, and every $x$ can be uniquely decomposed as
$x=x_1+x_2$ where $x \in S, x_2 \in S^\bot$.
Choose $x$ and let $x= x_n+x_r$, where $x_n \in \ker A$ and
$x_r \in (\ker A)^\bot$.
Write $x_r = a+b$, where $a \in {\cal R} A^T, b \in ({\cal R} A^T)^\bot$.
Note that $a = A^T z$ for some $z$, and so if $k \in \ker A$ then
$\langle A^T z, k \rangle = \langle z, A k \rangle = 0$ and so
$a=A^T z \in (\ker A)^\bot$.
Hence $b=x_r - a \in (\ker A)^\bot$.
Since $b \in ({\cal R} A^T)^\bot$, we see that
$\langle A^T (Ab),  b\rangle  = \|Ab\|^2 = 0$, and hence $b \in \ker A$,
and so
we see that $b = 0$ and so $x_r = a \in {\cal R} A^T$, the row space of $A^T$.
A: I maybe using not proper linear algebra terminology but I think you would understand the idea if this is still relevant. 
As you say, $A$ is an $m\times n$ matrix and $x$ is in $\Bbb{R}^n$. Matrix $A$ has rank $r$, so both row space and column space have this dimension ($=r$). 
The nullspace will have dimension $= n-r$. 
So there are r number of independent vectors spanning row space and n-r number of independent vectors spanning nullspace. 
Additionally, row space is orthogonal to nullspace (no row vectors can span nullspace and the other way around). This means r vectors that form row space are independent of n-r rows from nullspace. 
So, $r+(n-r)=n$ independent vectors. They can span any vector in $\Bbb{R}^n$ and we have $x$ in $\Bbb{R}^n$, so $x$ can be spanned by combination of those vectors.
Below is example, we want to get $x=x_r+x_n$:
$A=\begin{bmatrix}1&-1\\0&0\\0&0\end{bmatrix};\quad x=\begin{bmatrix}2\\0\end{bmatrix}$
Row space basis is just $h=\begin{bmatrix}1&-1\end{bmatrix}$, and nullspace basis is $g=\begin{bmatrix}1&1\end{bmatrix}$
So, solve this system:
$A=\begin{bmatrix}1&1\\1&-1\end{bmatrix}\times w=\begin{bmatrix}2\\0\end{bmatrix}$
to get $w=\begin{bmatrix}1\\1\end{bmatrix}$
Thus, $\begin{bmatrix}2\\0\end{bmatrix}=\begin{bmatrix}1\\1\end{bmatrix}+\begin{bmatrix}1\\-1\end{bmatrix}$
A: Lemma: If vector set {$r_{1}, r_{2}, \dots, r_{r}$} is the basis of row subspace and {$n_{1}, n_{2}, \dots, n_{n-r}$} is the basis of null subspace, {$r_{1}, r_{2}, \dots, r_{r}, n_{1}, n_{2}, \dots, n_{n-r}$} is the basis of $R^n$
So, any $v \in R^n$ can be written as linear combination of {$r_{1}, r_{2}, \dots, r_{r}, n_{1}, n_{2}, \dots, n_{n-r}$}, which is
$v=\sum_1^n\alpha_i{r_i}+\sum_1^{n-r}\beta_i{n_i}=v_r+v_n$
Lemma Proof:
If $v_r$ in row space and $v_n$ in null space, so $v_r=\sum_1^n\alpha_i{r_i}$ and $v_n=\sum_1^{n-r}\beta_i{n_i}$
$$
\begin{align}
v_r+v_n=0 &\implies v_r=-v_n \\
&\implies v_r \text{ linear dependent with } v_n \\
&\implies v_r, v_n \text{ in both subspaces } \\
&\implies v_r=v_n=0 \text{ (for orthogonal subspaces only intersect in 0)}\\
&\implies \alpha=\beta=0 \\
&\implies {r_{1}, r_{2}, \dots, r_{r}, n_{1}, n_{2}, \dots, n_{n-r}} \text{ linear independent} \\
&\implies {r_{1}, r_{2}, \dots, r_{r}, n_{1}, n_{2}, \dots, n_{n-r}} \text{ is the basis of }R^n
\end{align}
$$
