Integration and null function Let $ f: [a, b] \rightarrow {\mathbb {R}} $ be continuous and such that $$ \int_ {a} ^ {b} {f (x) g (x) dx} = 0 $$ for all $ g: [a, b] \rightarrow {\mathbb {R}} $ continuous with $ g (a) = g (b) = 0 $. Show that $ f $ is null in $ [a, b] $.
Test (Attempt): Let's see that $ f $ is null, that is, $ f (x) = 0 $, for every $ x \in [a, b]$. By absurdity. Let $c\in [a, b]$ be such that $ f (c) \neq 0 $. Suppose that $ f (c)> 0 $. Since $ f $ is continuous in $ [a, b] $, then for $ \epsilon = \frac {f (c)} {2}> 0 $, there exists $ \delta> 0 $ such that if $ x \in [a, b] \cap {(c- \delta, c + \delta)} $, then $ f (x)> 0 $.
Anyone have a suggestion?
 A: Since $f$ is continuous it is enough to show $\int_a^b f(t)^2 dt=0$. Let $\vert f(t)\vert\leq M$ for all $a\leq t\leq b$ and let $\varepsilon<(b-a)/2$. Then define $g=g_\varepsilon$ by 
$g(t):= f(a+\varepsilon) (t-a)/\varepsilon\text{ if } a\leq t<a+\varepsilon$,
$g(t)
:=f(t)\text{ if } a+\varepsilon\leq t\leq b-\varepsilon$ and
$g(t):=f(b-\varepsilon)(b-t)/\varepsilon\text{ if } b-\varepsilon<t\leq b$. Then by assumption $\int_{a+\varepsilon}^{b-\varepsilon} f(t)^2 dt+\int_a^{a+\varepsilon}f(t)g(t)dt+\int_{b-\varepsilon}^b f(t)g(t)dt=0$. This implies that 
$\int_{a+\varepsilon}^{b-\varepsilon} f(t)^2 dt\leq\int_a^{a+\varepsilon}\vert f(t)g(t)\vert dt+\int_{b-\varepsilon}^b \vert f(t)g(t)\vert dt$. The integral in the RHS may be estimated by $K\varepsilon$ with $K$ depending in $M$ only. So with $\varepsilon\to0$ you get 
$\int_{a}^{b
} f(t)^2 dt\leq0$.
Edit I
just realized that there is a similar question with good answers here:
here
A: Suppose then that 
$\exists y \in (a, b), \; f(y) \ne 0; \tag 1$
replacing $f(x)$ with $-f(x)$ if necessary, we may assume that
$f(y) > 0; \tag 2$
the continuity of $f(x)$ then allows us to assert the existence of some real
$\epsilon > 0 \tag 3$
such that
$x \in [y - \epsilon, y + \epsilon] \subset (a, b) \Longrightarrow f(x) \ge \dfrac{f(y)}{2}; \tag 4$ 
we may now define a function 
$g:[a, b] \to \Bbb R \tag 5$
as follows:
$x \in [a, y - \epsilon], \; g(x) = 0, \tag 6$
$x \in [y - \epsilon, y], \; g(x) = \dfrac{f(y)}{2}(x - (y - \epsilon)), \tag 7$
$x \in [y, y + \epsilon], \; g(x) = \dfrac{f(y)}{2}((y + \epsilon) - x), \tag 8$
$x \in [y + \epsilon, b], \; g(x) = 0;\tag 9$
then $g(x)$ is easily seen to be a continuous function on $[a,b]$ with
$g(a) = g(b) = 0; \tag{10}$
the graph of $g(x)$ is flat and fixed at $0$ for $x \in [a, y - \epsilon] \cup [y + \epsilon, b]$ and exhibits a positive triangular "spike" of height $\epsilon f(y)/2$ centered at $y$ with base $[y - \epsilon, y + \epsilon]$; it follows then that
$x \in [a, y - \epsilon] \cup [y + \epsilon, b] \Longrightarrow f(x)g(x) = 0, \tag{11}$
$x \in [y - \epsilon, y] \Longrightarrow f(x)g(x) \ge \dfrac{(f(y))^2}{4}(x - (y - \epsilon)), \tag{12}$
$x \in [y, y + \epsilon] \Longrightarrow f(x)g(x) \ge  \dfrac{(f(y))^2}{4}((y + \epsilon) - x); \tag{13}$
it is easy to see that $f(x)g(x) \ge 0$ is a continuous function on $[a,b]$ and that
$x \in (y - \epsilon, y + \epsilon) \Longrightarrow f(x)g(x) > 0, \; x \notin (y - \epsilon, y + \epsilon) \Longrightarrow f(x)g(x) = 0; \tag{14}$
it follows then that
$\displaystyle \int_a^b f(x)g(x) \; dx > 0, \tag{15}$
which contradicts our hypothesis that
$\displaystyle \int_a^b f(x) g(x) \; dx = 0; \tag{16}$
we are thus forced to conclude that
$f(x) = 0, \; \forall x \in [a, b]. \tag{17}$
$OE\Delta$.
