Proving existence of unique polynomial satisfying some integral I came across a problem that I was having some trouble with.
Fix a positive integer $n$. Let $f(x) \in C(R)$ be a (real valued) continuous function.
Show that there exists a unique polynomial $q(x) \in P_n(R)$, such that for every
polynomial $p(x) \in P_n(x)$ we have $\int^1_0 p(x)f(x)dx=\int^1_0 p(x)q(x)dx$.
I know that typically to solve uniqueness questions, you need to assume another $g(x)$ exists and then manipulate the resulting equation(s) to show that $g(x)=q(x)$. However, it's not so clear to me here how I should go about this here. I think that the $p(x)$ might be confusing me in this question.
If anyone can give me some pointers, it would be greatly appreciated. Thanks!
 A: Here's how you can claim uniqueness: Fix $f\in C(\Bbb{R})$, and suppose that both $g$ and $q$ satisfy the condition in question. This means we have
$$
\int_0^1\!p(x)f(x)\,dx = \int_0^1\!p(x)g(x)\,dx = \int_0^1\!p(x)q(x)\,dx
$$
for all $p\in P_n(\Bbb R)$. In particular, this property holds for $g(x) - q(x)$ (which is again in $P_n(\Bbb R)$). Then we have
$$
\int_0^1\!\left(g(x) - q(x)\right)g(x)\,dx = \int_0^1\!\left(g(x) - q(x)\right)q(x)\,dx
$$
so that
\begin{align*}
0 &= \int_0^1\!\left(g(x) - q(x)\right)g(x)\,dx - \int_0^1\!\left(g(x) - q(x)\right)q(x)\,dx\\
&= \int_0^1\!\left(g(x) - q(x)\right)g(x) - \left(g(x) - q(x)\right)q(x)\,dx\\
&= \int_0^1\!\left(g(x) - q(x)\right)\left(g(x) - q(x)\right)\,dx\\
&= \int_0^1\!\left(g(x) - q(x)\right)^2\,dx.
\end{align*}
However, $\left(g(x) - q(x)\right)^2$ is continuous and $\left(g(x) - q(x)\right)^2\geq 0$ for all $x\in [0,1]$, so that $\left(g(x) - q(x)\right)^2 = 0$ for all $x\in [0,1]$ (because if $h$ is continuous and nonnegative on $I = [a,b]$ and $\int_a^b\!h = 0$, then $h\equiv 0$ on $[a,b]$). This implies that $g(x) = q(x)$ on $[0,1]$, and since they are polynomials, they must then be the same polynomial.
Alternatively, we can view this same proof in terms of linear algebra language:
$\langle p,q\rangle = \int_0^1 pq$ defines an inner product on $P_n(\Bbb R)$. In the same manner as before, if $g,q$ both satisfy your desired condition, then
\begin{align*}
\langle q - g,q\rangle &= \langle q - g,g\rangle\\
\implies 0 &= \langle q - g,q\rangle - \langle q - g,g\rangle\\
&= \langle q - g,q - g\rangle\\
&= \left|\left| q - g\right|\right|^2,
\end{align*}
which implies that $q - g = 0$, or $q = g$. (Added because you tagged this "linear algebra.")
