Prove that $f \in L^2(\mathbb{R})$ and $||f||_2 \leq 1$. The entire question reads:
Let $f$ be a Lebesgue measurable function on $\mathbb{R}$ with the property that $\sup_{\{g \in L^2(\mathbb{R}):||g||_2 \leq 1\}}\int_{\mathbb{R}}|fg|d \lambda \leq 1$. Prove that $f \in L^2(\mathbb{R})$ and $||f||_2 \leq 1$.
I'm not quite sure where to begin on this problem. I'm trying to get more practice with $L^p$ spaces, but it's clear I'm still lacking in skill and know-how. Any tips or tricks are greatly appreciated. 
 A: For every $n\in\mathbb{N}$ let
$$
A_n := \{x\in [-n,n]:\ |f(x)| \leq n\},
\qquad
f_n := f \chi_{A_n},
$$
and define the linear functional $T_n\colon L^2\to\mathbb{R}$
$$
T_n(g) := \int_{\mathbb{R}} f_n g.
$$
Clearly $T_n$ is a bounded functional in $L^2$, since,
by Holder's inequality,
$$
|T_n(g)| \leq \int_{\mathbb{R}} |f_n g| \leq \|f_n\|_2 \|g\|_2.
$$
Since
$$
|T_n(f_n)| = \left| \int_{\mathbb{R}} f^2\chi_{A_n}\right|
= \int_{\mathbb{R}} f_n^2 = \|f_n\|_2^2
$$
we can thus conclude that $\|T_n\| = \|f_n\|_2$.
Moreover, $|f_n g| \nearrow |fg|$, so that
$$
\sup_n |T_n(g)| \leq \int_{\mathbb{R}} |fg| < +\infty.
$$
By the Uniform Boundedness Principle we can conclude that the sequence $(T_n)$ converges to a bounded linear functional $T$, and that
$$
\|T\| \leq \liminf_n \|T_n\| < +\infty.
$$
On the other hand, by the monotone convergence theorem,
$$
\liminf_n \|T_n\| = \liminf_n \|f_n\|_2 = \left(\int_{\mathbb{R}} |f|^2\right)^{1/2},
$$
hence $f\in L^2$.
Finally, taking $g = f / \|f\|_2$ in the assumption, one get
$$
\int_{\mathbb{R}} |fg| = \|f\|_2 \leq 1.
$$
A: Let $f_n\colon x\mapsto  f(x)$ if $\left\lvert f(x)\right\rvert \leqslant n$ and $x\in[-n,n]$ and zero $f_n\colon x\mapsto 0$ if one of the previous conditions is not satisfied. Then $f_n$ is square integrable. Let us fix $n$ and consider $$g\colon x\mapsto \frac{f_n(x)}{\left\lVert f_n\right\rVert_2    +1/n }.$$
Then $\left\lVert g\right\rVert_2\leqslant 1$ and thus  $$\int
f(x)^2\mathbf 1_{[-n,n]}\left(f(x)\right)\mathbf 1_{[-n,n]}(x)\mathrm dx\leqslant 1          .$$
Since $n$ is arbitrary, the monotone convergence theorem gives the wanted result.
