A First Course in Linear Algebra, Beezer, R., 2008
Page 403
Problem C10

Question
In the vector space C3, compute the vector representation ρB (v) for the basis B and vector v below. \[ B = \left\{ \begin{pmatrix} 2 \\ -2 \\ 2 \end{pmatrix}, \begin{pmatrix} 1 \\ 3 \\ 1 \end{pmatrix}, \begin{pmatrix} 3 \\ 5 \\ 2 \end{pmatrix} \right\} \]

\[ v = \begin{pmatrix} 11 \\ 5 \\ 8 \end{pmatrix} \]

ANSWER
v is a linear combination of the vectors in B which looks like this:

\[ c_1 \begin{pmatrix} 2 \\ -2 \\ 2 \end{pmatrix} + c_2 \begin{pmatrix} 1 \\ 3 \\ 1 \end{pmatrix} + c_3 \begin{pmatrix} 3 \\ 5 \\ 2 \end{pmatrix} = \begin{pmatrix} 11 \\ 5 \\ 8 \end{pmatrix} \]

which is the equivalent of

2c1 + 1c2 + 3c3 =11
-2c1 + 3c2 + 5c3 =5
2c1 + 1c2 + 2c3 =8

which in matrix form is:

\[\begin{pmatrix}2 & 1 & 3 &|&11\\-2 & 3 & 5&|&5 \\2 & 1 & 2 &|&8 \\\end{pmatrix}\]

Perform the below row operations
R2= R2+R1
R3= R3-R1
to arrive at the below matrix:

\[\begin{pmatrix}2 & 1 & 3 & |&11\\0 & 4 & 8 & |& 16\\0 & 0 & -1 &|&-3\\\end{pmatrix}\]

Solving for c3:
-1c3=-3
= 3

Solving for c2 using c3=-3:
4c2+8(-3)= 16
4c2=-8
c2= -2

Solving for c1 using c3=-3 and c2=-2:
2c1-2+9=11
2c1=4
c1=2

answer is: \[\begin{pmatrix}2 \\ -2 \\ 3\\\end{pmatrix}\]

# matrix B/vector v
B <- matrix(c(2, 1, 3, -2, 3, 5, 2, 1, 2), nrow = 3, byrow = TRUE)
v <- c(11, 5, 8)

# Solve 
co <- solve(B, v)

# Print the coefficients
print(co)
## [1]  2 -2  3