How to get the coefficients of a vector? 
Question: Suppose we have a subspace $V$ of $\mathbb{R}^n$ given by a basis $v_1,\ldots,v_k\in\mathbb{R}^n$. Suppose we are given a vector $v\in\mathbb{R}^n$ which we know lies in $V$. Is there a general procedure for computing the coefficients $a_i\in\mathbb{R}$ for which
  $$v=a_1v_1+\cdots+a_kv_k?$$

I know how to do it when $V=\mathbb{R}^n$: We just construct a matrix
$$A=\begin{pmatrix}| & & | \\ v_1 & \cdots & v_n \\ | & & |\end{pmatrix}$$
with the vectors $v_i$ as columns and then get
$$\begin{pmatrix}a_1\\ \vdots\\a_n\end{pmatrix}=A^{-1}v.$$
But if $k<n$, how to do it?

Example: Let $V$ be the $3$-dimensional subspace of $\mathbb{R}^5$ given by
  $$V=\mathrm{span}\{(0,1,2,3,4),(-1,-2,-3,-4,-5),(1,0,1,0,1)\}=:\mathrm{span}\{v_1,v_2,v_3\}$$
  and let
  $$v=(1, -3, -1, -5, -3).$$
  Find, in a systematic way, $a_i\in\mathbb{R}$ such that
  $$v=a_1v_1+a_2v_2+a_3v_3.$$

 A: This problem is the very general problem of solving an $n\times k$ system of linear equations $Ax=v$ where the columns of $A$ are rthe coordinates of your family of vectors $v_1, \dots, v_k$.
The method consists in using Gauß's pivot method. In detail, consider the  matrix $(A|v)$ of size $n\times (k+1)$ augmented with the coordinates of $v$.
Use elementary operations on rows until the submatrix $A$ of $(A|v)$  is upper triangular. It will have rank $r\le k$ 


*

*If the augmented matrix has rank $>r$, $v$ is not in $V$, so there's no solution.

*If the augmented matrix has rank $r$, $v$ is in $V$ and $r$ vectors of $\{v_1, \dots, v_k\}$ are a basis for $V$. Consider the $r\times r$-submatrix $B$ made up of  the $r$ corresponding columns, plus the last column, and the $r$ first rows. You then have an augmented matrix $(B|w)$, where $w$ is the transform of $v$, truncated after the $r$-th row.

*Continue pivoting until $B$ becomes the $r\times r$ unit matrix.

*The $r$ first coefficients are the last column and the $n-r$ last coefficients are $0$.

*The solution is unique if $r=k$. If $r<k$ oy may choose coefficients for $v_{r+1},\dots, v_k$ as you please, and deduce the coefficients for $v_1, \dots, v_r$.


In your example, the system has rank $3$, but is not compatible, i.e. $v$ in not in $V$, if my computations are exact.
A: When you find the components by $A^{-1}v$, you're converting $v$--as expressed in the canonical orthonormal basis--into the basis you want to describe it in.
So for this case, you can use the same approach--if you can express $v$ in terms of one basis that is intrinsic to the subspace $V$ and then write the change of basis matrix $A$.
That probably doesn't help you, since you don't have $v$ in terms of any basis intrinsic to the subspace.
Instead, consider what happens when you take inner products of $v$ with the basis vectors:
$$\langle v, v_i \rangle = a_1 \langle v_1, v_i \rangle + a_2 \langle v_2, v_i \rangle + a_3 \langle v_3, v_i \rangle$$
Here, the inner product is that of $\mathbb R^5$. Using $i \in \{1, 2, 3\}$, do you see how you can use these inner products (which you can compute, given that you know the components of these vectors with respect to the standard basis) to derive three equations for the unkonwn coefficients $a_1, a_2, a_3$?
