Solving a polynomial equation Find a polynomial $f$ of degree at the most 2, such that for every polynomial $g$ we have
$$\int_0^1 f(x)g(x)\mathrm{d}x = g\left(\frac{1}{2}\right)$$
I started off my assuming $f(x) = a_0 + a_1x + a_2x^2$ and integrating for $g(x) = 1$, $x$ and $x^2$ and solving the equations for $a_i$ but it doesn't seem like the results I get satisfy the equation for all $g$. What am I doing wrong?
 A: There is no solution. Polynomials are a dense subset of $L^2(0,1)$ or $C^0(0,1)$. The only working choice is $f(x)=\delta(x-1/2)$, but it is a distribution, not a polynomial.
A: Note that your $f$ has to satisfy the first $3$ equations you got hence it has to satisfy $a_0=-\frac{3}{2},a_1=15,a_2=-15$ but since you found a counter example that means that $f(x)=\frac{-3}{2}+15x-15x^2$ doesn't satisfy the condition that means that no polynomial satisfy the condition.By the way the polynomial I used for the 4th equation was $g(x)=x^4$.
A: We can reduce the problem to the case that $g(x) = x^k$ for $k \in \mathbb{N}$.  We find that if $f(x) = a_0 + a_1 x + a_2x^2$, then 
$$ \int_0^1 f(x)g(x) dx = g(1/2) ~~ \textrm{ implies } ~~ {a_0 \over k+1} + {a_1 \over k+2} + {a_2 \over k+3} = {1 \over 2^k} ~~ \forall k \in \mathbb{N}.$$
Writing this equation for each of $k = 0,1,2$ we get three equations in three variables, which can be expressed as the augmented matrix
$$ \left[ \begin{array}{ccc|c} 1 & 1/2 & 1/3 & 1 \\ 1/2 & 1/3 & 1/4 & 1/2 \\ 1/3 & 1/4 & 1/5 & 1/4 \end{array} \right].$$
Reducing this we find that if $f$ exists, its coefficients must be 
$$ a_0 = -3/2, ~~ a_1 = 15, ~~ a_2 = -15. $$
Plugging these back into the first display,
$$ {-3/2 \over k+1 } + {15 \over k+2} - { 15 \over k+3 } = {1 \over 2^k} $$
which simplifies to 
$$ 2^k(-1.5k^2 + 7.5k + 6) - k^3 -6k^2-11k-6 = 0 $$
and we need this equation to hold for all nonnegative $k$.  It does connivingly hold for $k = 3$ as well, but for no other choices of $k$.
