Find a polynomial $q \in \mathcal{P}_{2}(\mathbb{R})$ such that $p(\frac{1}{2}) = \int p(x)q(x) dx$ 
Find a polynomial $q \in \mathcal{P}_{2}(\mathbb{R})$ such that 
$$p \left(\frac{1}{2} \right) = \int_{0}^{1} p(x)q(x) dx$$
for every $p \in \mathcal{P}_2(\mathbb{R})$.

I am practicing this using Linear Algebra Done Right. Specifically, it appears I need to use the Riesz Representation Theorem:

Suppose $V$ is finite dimensional and $\phi$ is a linear functional on
  $V$. Then there is a unique vector $u \in V$ such that
$$\phi(v) = \langle v, u \rangle$$
for every $v \in V$.

Particularly, it appears to find the $u$ one has to use 
$$u = \overline{\phi(e_1)}e_1 + \dots+ \overline{\phi(e_n)}e_n$$
where $\overline{\phi(e_i)}$ is the complex conjugate of $\phi$  and $e_i$ is an orthonormal basis vector.
Attempt
So I have found an orthonormal basis for $\mathcal{P}_2(\mathbb{R})$ given that we are dealing with polynomials. Let $e_{i}(x)$ be the orthonormal vector. I feel then
$$q(x) = \overline{\phi \left(e_{1} \left(\frac{1}{2} \right) \right)} e_{1} + \overline{\phi \left(e_{2} \left(\frac{1}{2} \right) \right)} e_{2} + \overline{\phi \left(e_{3} \left(\frac{1}{2} \right) \right)} e_{3}$$
Is this the right path to take?
 A: Hint. Let $q(x)=ax^2+bx+c$ then, by linearity, it suffices that the equality holds for the base $\{1,x,x^2\}$ of $ \mathcal{P}_{2}(\mathbb{R})$, that is
$$\frac{1}{2^k}=\int_{0}^{1} x^k(ax^2+bx+c) dx=\frac{a}{k+3}+\frac{b}{k+2}+\frac{c}{k+1}$$
for $k=0,1,2$.
A: If $q(x)$ is such a polynomial, then it is easy to see that $q(x)-1$ must be orthogonal to $1$ and $x-\frac{1}{2}$ with respect to the inner product $\langle \_,\_\rangle$ on $\mathcal{P}_2(\mathbb{R})$ defined by
$$\langle a(x),b(x)\rangle:=\int_0^1\,a(x)\,b(x)\,\text{d}x\text{ for all }a(x),b(x)\in\mathcal{P}_2(\mathbb{R})\,.$$
Thus, we apply the Gram-Schmidt orthonormalization on the basis $\left\{1,x-\frac{1}{2},x^2\right\}$ to get
$$\begin{align}q(x)-1&\propto x^2-\frac{\langle 1,x^2\rangle}{\langle 1,1\rangle}\,1-\frac{\langle x-\frac12,x^2\rangle}{\langle x-\frac12,x-\frac12\rangle}\,\left(x-\frac12\right)
\\&=x^2-\frac13-\left(\frac{\frac{1}{4}-\frac{1}{6}}{\frac13-\frac12+\frac14}\right)\,\left(x-\frac12\right)\,.\end{align}$$
That is,
$$q(x)-1\propto x^2-x+\frac{1}{6}\text{ or }q(x)=A\,\left(x^2-x+\frac16\right)+1$$
for some constant $A$.  Since $\langle x^2,q(x)\rangle=\frac14$ must hold, we conclude that
$$\frac14=A\,\left(\frac15-\frac14+\frac1{18}\right)+\frac13\,,$$
whence
$$A=-15\text{ or }q(x)=-15x^2+15x-\frac32\,.$$  Interestingly, it turns out that, with $q(x)=-15x^2+15x-\frac32$,
$$\int_0^1\,p(x)\,q(x)\,\text{d}x=p\left(\frac12\right)$$
for all $p(x)\in\mathbb{C}[x]$ of degree at most $3$.
A: For the space of polynomials $\mathcal{P}_2(\mathbb{R})$, you can define
$$
(P,Q) =\int_0^1 P(x)Q(x)dx
$$
for any pair $P,Q\in \mathcal{P}_2(\mathbb{R})$ (actually degree does not matter at all). Check that this is a inner product on the linear space $\mathcal{P}_2(\mathbb{R})$. Also note that, the linear functional $\mathrm{ev}_{a}:\mathcal{P}_2\to \mathbb{R}$ which sends $x^k\mapsto a^k$ for all $k$, sends $P(x)\mapsto P(a)$. Combine these two with Riesz Representation Theorem to get what you want.
