For the vectors $\mathbf{u}_1, \mathbf{u}_2, \cdots, \mathbf{u}_k \in \mathbf{R}^n$, let $$ g(\mathbf{u}_1, \mathbf{u}_2, \cdots, \mathbf{u}_k)= \left| \begin{array}{cccc} \mathbf{u}_1 \cdot \mathbf{u}_1 & \mathbf{u}_1 \cdot \mathbf{u}_2 & \cdots & \mathbf{u}_1 \cdot \mathbf{u}_k \\ \mathbf{u}_2 \cdot \mathbf{u}_1 & \mathbf{u}_2 \cdot \mathbf{u}_2 & \cdots & \mathbf{u}_2 \cdot \mathbf{u}_k \\ \vdots & \vdots & \ddots & \vdots \\ \mathbf{u}_k \cdot \mathbf{u}_1 & \mathbf{u}_k \cdot \mathbf{u}_2 & \cdots & \mathbf{u}_k \cdot \mathbf{u}_k \end{array} \right| $$ where $k \ge 1$.
(1) Prove that $g(\mathbf{u}_1, \mathbf{u}_2, \cdots, \mathbf{u}_k)=0$ if and only if $\{\mathbf{u}_1, \mathbf{u}_2, \cdots, \mathbf{u}_k\}$ is linearly independent.
(2) Let ${\mathbf{w}_1, \mathbf{w}_2, \cdots, \mathbf{w}_m}$ be a basis for a subspace $W$ of $\mathbf{R^n}$. Prove that for every vector $\mathbf{v} \in \mathbf{R}^n$, $$ \lVert \mathrm{perp}_W (\mathbf{v}) \rVert^2 = \frac{g(\mathbf{v}, \mathbf{w}_1, \mathbf{w}_2, \cdots , \mathbf{w}_m)}{g(\mathbf{w}_1, \mathbf{w}_2, \cdots , \mathbf{w}_m)}. $$
Hint: The key word is Gramian matrix.