Let $b \in \mathbb R^m$. If $p$ is vector that is span $a_1,a_2,\cdots,a_m \in \mathbb R^m$, say the criterion and explain that $p$ is orthogonal projection of vector $b$ on subspace that is span $a_1,a_2,\cdots,a_m \in \mathbb R^m$
I know for $2D$ that $p=a\frac{a^Tb}{a^Ta}$, and I know in general form that $p=A(A^TA)^{-1}A^Tb$ such that column of $A$ is $a_1,a_2,\cdots,a_m$, but i have no idea maybe using pythagor theorem or something like that