# Linear Algebra - Vector and Set of Vectors
## Linear Combination
Given a set of vectors S, $S=\{u_1,u_2,...,u_n \}$, Linear combination of S is
$$c_1u_1+c_2u_2+...+c_nu_n\text{ , such that }c_1,c_2,...,c_n\in\mathbb{R}$$
## Span
Span(S) is linear combiantion of S
$$Span(S)=\{c_1u_1+c_2u_2+...+c_nu_n|c_1,c_2,...,c_n\in\mathbb{R}\}$$
## How to show vector is in a span or not?
Let's just took some examples.
### Example 1
:::info
Given a span $S=\{
\left[ {\begin{array}{cc}
2\\0\\1\\
\end{array} } \right]
,\left[ {\begin{array}{cc}
1\\1\\0\\
\end{array}}\right]\}$, is vector $\vec{A}=\left[ {\begin{array}{cc}
0\\1\\0\\
\end{array}}\right]$ in the $span(S)$?
:::
Ans:
:::spoiler
Again, to check if $\vec{B}$ is in span, we can check if there is a linear combination of $(2,0,1)$ and $(1,1,0)$ equals $\vec{B}$, we can list some equations down:
\begin{cases}
2C_1+1C_2=0 \\
0C_1+1C_2=1 \\
1C_1+0C_2=0
\end{cases}
Since $C_1=0$ and $C_2=0=1$ is impossible, $\vec{A} \notin Span(S)$
:::
### Example 2
:::info
Given a span $S=\{
\left[ {\begin{array}{cc}
2\\0\\1\\
\end{array} } \right]
,\left[ {\begin{array}{cc}
1\\1\\0\\
\end{array}}\right]\}$, is vector $\vec{B}=\left[ {\begin{array}{cc}
8\\2\\3\\
\end{array}}\right]$ in the $span(S)$?
:::
Ans:
:::spoiler
Again, to check if $\vec{B}$ is in span, we can check if there is a linear combination of $(2,0,1)$ and $(1,1,0)$ equals $\vec{B}$, we can list some equations down:
\begin{cases}
2C_1+1C_2=8 \\
0C_1+1C_2=2 \\
1C_1+0C_2=3
\end{cases}
We can get that $C_1=3$ and $C_2=2$, such that$\vec{B}=3\left[ {\begin{array}{cc}
2\\ 0\\1\\
\end{array} } \right]+2\left[ {\begin{array}{cc}
1\\1\\0\\
\end{array}}\right]$. Therefore, $\vec{B} \in Span(S)$
:::
## How about a span+vector?
### Example 1
:::info
Given vectors
$\vec{p}=\left[ {\begin{array}{cc}
-1\\0\\0\\
\end{array} } \right]
,\vec{u_1}=\left[ {\begin{array}{cc}
2\\0\\1\\
\end{array} } \right]
,\vec{u_2}=\left[ {\begin{array}{cc}
1\\1\\0\\
\end{array}}\right]$, and $S=\{\vec{u_1}, \vec{u_2}\}$,
is vector $\vec{A}=\left[ {\begin{array}{cc}
0\\1\\0\\
\end{array}}\right]$ in the $\vec{p}+span(S)$?
:::
Ans:
:::spoiler
First of all, we can write down that
$$\vec{A}=\vec{p}+C_1\vec{u_1}+C_2\vec{u_2}\rightarrow \vec{A}-\vec{p}=C_1\vec{u_1}+C_2\vec{u_2}$$
In this form, we can write down some equations again.
$$
\begin{cases}
2C_1+1C_2=0-(-1) \\
0C_1+1C_2=1-0 \\
1C_1+0C_2=0-0
\end{cases}\rightarrow\begin{cases}
2C_1+1C_2=1 \\
0C_1+1C_2=1 \\
1C_1+0C_2=0
\end{cases}
$$
We can get that $C_1=0$ and $C_2=1$, so $\vec{A}\in\vec{p}+Span(S)$
:::
### Example 2
:::info
Given vectors
$\vec{p}=\left[ {\begin{array}{cc}
-1\\0\\0\\
\end{array} } \right]
,\vec{u_1}=\left[ {\begin{array}{cc}
2\\0\\1\\
\end{array} } \right]
,\vec{u_2}=\left[ {\begin{array}{cc}
1\\1\\0\\
\end{array}}\right]$, and $S=\{\vec{u_1}, \vec{u_2}\}$,
is vector $\vec{B}=\left[ {\begin{array}{cc}
8\\2\\3\\
\end{array}}\right]$ in the $\vec{p}+span(S)$?
:::
Ans:
:::spoiler
Just like last problem, we can write down that
$$\vec{B}=\vec{p}+C_1\vec{u_1}+C_2\vec{u_2}\rightarrow \vec{B}-\vec{p}=C_1\vec{u_1}+C_2\vec{u_2}$$
In this form, we can write down some equations again.
$$
\begin{cases}
2C_1+1C_2=8-(-1) \\
0C_1+1C_2=2-0 \\
1C_1+0C_2=3-0
\end{cases}\rightarrow\begin{cases}
2C_1+1C_2=9 \\
0C_1+1C_2=2 \\
1C_1+0C_2=3
\end{cases}
$$
Since $C_1=3$ and $C_2=2=3 is impossible$, $\vec{B}\notin\vec{p}+Span(S)$
:::