Solution (source code)

= Solution

For a <basis> $v_1,\ldots,v_d$ of the <real vector space> $V$, the <Gram-Schmidt process> constructs an <orthonormal basis> successively:
$$
w_j=v_j-\sum_{i<j}\langle v_j,e_i\rangle e_i,\qquad e_j=\frac{w_j}{\sqrt{\langle w_j,w_j\rangle}}.
$$
The <inner product> makes $w_j$ <orthogonal> to all earlier $e_i$. Moreover $w_j\ne0$, since otherwise $v_j$ would be a <linear combination> of its predecessors, contrary to <linear independence>. Induction gives $\operatorname{span}(e_1,\ldots,e_j)=\operatorname{span}(v_1,\ldots,v_j)$. Starting with a <basis> of a <linear subspace> $U$ and extending it to a <basis> of $V$ gives the same construction with the first $r=\dim U$ vectors spanning $U$.

The <orthogonal complement> is $U^\perp=\{v\in V:\langle v,u\rangle=0\text{ for every }u\in U\}$. For every $v\in V$, set $u=\sum_{i=1}^r\langle v,e_i\rangle e_i$. Then $u\in U$ and $v-u\in U^\perp$. If $w\in U\cap U^\perp$, then $\langle w,w\rangle=0$, so $w=0$ by definiteness of the <inner product>. Thus the <direct sum> is
$$
\boxed{V=U\oplus U^\perp}.
$$
This also covers $U=0$ and $U=V$.

For the <polynomial> space, the form is immediately a <symmetric bilinear form>, and $(f,f)=f(1)^2+f(2)^2+f(3)^2\geq0$. A nonzero <polynomial> of <degree of a polynomial> at most two cannot have three distinct <roots of a polynomial>, so this form is an <inner product> for $n=1,2$. For $n\geq3$, the nonzero <polynomial> $(x-1)(x-2)(x-3)$ has $(f,f)=0$. Therefore, among the stipulated positive <integers>,
$$
\boxed{n\in\{1,2\}}.
$$