Definition: The orthogonal projection of $V$ onto $U$, $P_U$, is defined by $P_U(v) = u$, where $v = u + u'$ for $u ∈ U$ and $u' ∈ U^{\perp}$. Furthermore, if $(e_1, \ldots, e_m)$ is an orthonormal basis of $U$, then $P_U(v) = \sum_{i=1}^m\langle v, e_i\rangle e_i$, for all $v ∈ V$.
Now, given the following question, is my answer correct?
Let $(e_1, e_2, e_3, e_4)$ be an orthonormal basis of a 4 dimensional vector space V. Let $U = \mathrm{span}(e_1, e_3)$. What is $P_U(5e_1 + 6e_2 + 7e_3 + 8e_4)$?
Answer:
$$\langle (5e_1 + 6e_2 + 7e_3 + 8e_4), e_1\rangle e_1 + \langle (5e_1 + 6e_2 + 7e_3 + 8e_4), e_2\rangle e_2 + \langle (5e_1 + 6e_2 + 7e_3 + 8e_4), e_3\rangle e_3 + \langle(5e_1 + 6e_2 + 7e_3 + 8e_4), e_4\rangle e_4$$
Your answer isn't quite correct as $\{e_1, e_2, e_3, e_4\}$ is an orthonormal basis for $V$, not $U$. Using the orthonormal basis $\{e_1, e_3\}$ for $U$, you obtain
\begin{align*} & P_U(5e_1 + 6e_2 + 7e_3 + 8e_4)\\ =&\ \langle 5e_1 + 6e_2 + 7e_3 + 8e_4, e_1\rangle e_1 + \langle 5e_1 + 6e_2 + 7e_3 + 8e_4, e_3\rangle e_3. \end{align*}
Note however that this can be greatly simplified by using the bilinearity of the inner product together with the fact that $\{e_1, e_2, e_3, e_4\}$ is orthonormal. For example, $$\langle 8e_2 + 9e_3, e_2\rangle e_2 = 8\langle e_2, e_2\rangle e_2 + 9\langle e_3, e_2\rangle e_2 = 8(1)e_2 + 9(0)e_2 = 8e_2.$$