Integration theorem: enough assumptions? 
Let $f:[a,b]\to\mathbb{R}$ be a continious function. Show that if $$\int_a^b f(x)g(x)dx=0$$
  for all continious functions $g:[a,b]\to\mathbb{R}$ with $g(a)=g(b)=0$, then  $f(x)=0$ $\forall x\in[a,b]$

I have difficulties proving this question. Consider for example $g(x)=0$ $\forall x\in[a,b]$, then assumptions still hold but $f(x)$ can be anything (f.i. $f(x)=1\neq0$). Could anyone tell me if this reasoning is correct? 
 A: Your reasoning is wrong: the hypothesis asks that the integral be zero for all continuous $g: [a,b] \to \mathbb{R}$ with $g(a) = g(b) = 0$, not just for the particular choice $g = 0$.
So $f = 1$ is invalidated because of the function $g$ which is a nonlinear quadratic which is $0$ at both $a$ and $b$.
A: The proof starts like this:
Suppose, by contraddiction that 
$ \exists x_0 \ \in \ (a,b) \ :\ f(x_0)>0 $ then $ \exists \delta>0 \ :\ f(x)>0 \ \ \forall x \in(x_0-\delta,x_0+\delta) $
Can you reach the contraddiction?
A: Note that if $f$ would satisfy $f(a) = f(b) = 0$, you could take $g = f$ and get $\int_a^b f^2(x) \, dx = 0$ and since $f^2(x)$ is continuous and non-negative, you would immediately get $f(x) \equiv 0$. In general, you can modify $f$ continuously so that it stays the same on $[a + \frac{1}{n}, b - \frac{1}{n}]$ but drops down to zero afterwards. Define
$$ g_n(x) =
\begin{cases} f \left( a + \frac{1}{n} \right) n(x-a) & a \leq x \leq a + \frac{1}{n}, \\
f(x) & a + \frac{1}{n} \leq x \leq b - \frac{1}{n}, \\
-f \left( b - \frac{1}{n} \right)n(x - b) & b - \frac{1}{n} \leq x \leq b. \end{cases} $$
Then $g_n(a) = g_n(b) = 0$, the function $g_n$ is continuous and
$$ 0 = \int_a^b f(x)g_n(x) \, dx = \int_{a+\frac{1}{n}}^{b-\frac{1}{n}} f^2(x) \, dx + \operatorname{Junk}_n$$
where $\operatorname{Junk}_n \to 0$ where $n \to 0$ (show this by showing that $\operatorname{Junk}_n \leq \frac{2M}{n}$ where $|f| \leq M$). Taking the limit, you obtain the required result.
