$f,g$ are nonnegative decreasing and $\int_0^x f \le \int_0^x g$ for each $x \in [0,1]$ then $\int_0^1 f^2 \le \int_0^1 g^2$ Here's what I am trying to prove:
Let $f,g :[0,1] \to \mathbb R$ be nonnegative decreasing functions and suppose that $\int_0^x f \le \int_0^x g$ holds for each $x \in [0,1]$ then show that $\int_0^1 f^2 \le \int_0^1 g^2$.
I tried to prove it but I think there's possibly some errors. Here's my attempt, nonetheless:
Let $\alpha =\sup \{ x\in [0,1] : g(x)<f(x) \}$. Now, if $y>\alpha$ then $g(y)\ge f(y)$. Since $g$ and $f$ are decreasing, we have $(g-f)(g+f)\ge (g(1)+f(1) )(g-f)$ on $(\alpha,1]$ and hence $\int_\alpha ^1 (g^2-f^2) \ge0$ since $g-f \ge 0$ on $(\alpha,1].$
Since $g$ and $f$ are decreasing, we have $(g-f)(g+f)\ge (g(1)+f(1) )(g-f)$ on $[0,\alpha)$ and hence $\int_0 ^\alpha (g^2-f^2) \ge0$ since $\int_0^\alpha (g-f) \ge 0$ by assumption.
And thus, the result follows.

Is my attempt correct? Also alternative proofs are welcome!
 A: As pointed out in the comments, your proof is not correct because $(g-f)(g+f)\ge (g(1)+f(1) )(g-f)$ does not necessarily hold for all $x \in [0, \alpha)$. Also I cannot see where the condition $\int_0^x f \le \int_0^x g$ for all $x \in [0, 1]$ is used.

For a proof we can use the “Second mean value theorem for definite integrals” in the following form:

Let $h: [a, b] \to \Bbb R$ be a nonnegative, decreasing function, and $\phi: [a, b] \to \Bbb R$ be an integrable function. Then
$$
 \int_a^b h(x) \phi(x) \, dx = h(a+) \int_a^c \phi(x) \, dx
$$
for some $c \in [a, b]$.

Here $h(a+)$ denotes the one-sided limit $\lim_{x \to a+} h(x)$.
This can be applied (twice) to our problem: There are $c, d \in [0, 1]$ such that
$$
\begin{align}
\int_0^1 \bigl(g(x)^2-f(x)^2\bigr)\, dx &= \int_0^1 g(x)\bigl(g(x)-f(x)\bigr) \, dx
+ \int_0^1 f(x)\bigl((g(x)-f(x)\bigr) \, dx \\
  &= g(0+) \int_0^c \bigl(g(x)-f(x)\bigr) \, dx + f(0+) \int_0^d \bigl(g(x)-f(x)\bigr) \, dx \\
&\ge 0 \, .
\end{align}
$$

Remark: A proof of the second mean value theorem for Lebesgue-integrable functions can be found e.g. in Hobson, E. W. (1909). On the Second Mean-Value Theorem of the Integral Calculus. https://doi.org/10.1112/plms/s2-7.1.14 .
A: Let $F(x) = \int_0^x f(t) \, dt$, and $G(x) = \int_0^x g(t) \, dt$.  Integrating by parts we obtain
$$ \int_0^1 f(t)^2 \, dt = F(1)f(1) - \int_0^1 F(t) \, df(t) .$$
Since $df$ is a negative measure, it follows that this is less than or equal to
$$ G(1)f(1) - \int_0^1 G(t) \, df(t) = \int_0^1 f(t) g(t) \, dt .$$
Therefore by Cauchy-Schwarz, we have
$$ \int_0^1 f^2 \le \int_0^1 fg \le \left(\int_0^1 f^2\right)^{1/2} \left(\int_0^1 g^2\right)^{1/2} .$$
A: Lemma: $a_1\ge a_2\ge\cdots\ge a_n\ge0$ and $b_1\ge b_2\ge\cdots\ge b_n\ge0$. $\sum_{i=1}^ka_i\le\sum_{i=1}^kb_i$ for all $k$. Then $$\sum_{i=1}^na_i^2\le\sum_{i=1}^nb_i^2$$.
Proof:
Let $\ell_k= \sum_{i=1}^ka_i-\sum_{i=1}^kb_i$. The condition says $\ell_k\le0$ for all $1\le k\le n$. By definition, $\ell_0=0$. Note that $a_k-b_k=\ell_k-\ell_{k-1}$ for all $1\le k\le n$.
$$\begin{aligned}
\sum_{i=1}^na_i^2-\sum_{i=1}^nb_i^2
&=\sum_{i=1}^n(a_i+b_i)(a_i-b_i)\\
&=\sum_{i=1}^n(a_i+b_i)(\ell_i-\ell_{i-1})\\
&=(a_n+b_n)\ell_n-(a_1+b_1)\ell_0 +  \sum_{i=1}^{n-1}((a_i-a_{i+1})+(b_i-b_{i+1}))\ell_i\\
&\le0
\end{aligned}$$
The lemma is a slight variant of Karamata's inequality with the convex function $f=x^2$.
The proposition in the question is the continuous variant of the lemma.

Fix a positive integer $n$. Let $\ a_i=\int_{\frac{i-1}n}^\frac in f$, $\ b_i=\int_{\frac{i-1}n}^\frac in g$ for all $1\le i\le n$.

*

*$f$ and $g$ are nonnegative decreasing implies $a_1\ge a_2\ge\cdots\ge a_n\ge0$ and $b_1\ge b_2\ge\cdots\ge b_n\ge0$.

*$\int_0^x f \le \int_0^x g$ holds for each $x \in [0,1]$ implies $\sum_{i=1}^ka_i=\int_0^\frac kn f \le \int_0^\frac kn g=\sum_{i=1}^kb_i$ for all $k$.

The lemma tells that
$\sum_{i=1}^na_i^2\le\sum_{i=1}^nb_i^2$. Multiplying by $n$, we have
$$\sum_{i=1}^nna_i^2\le\sum_{i=1}^nnb_i^2.$$ Letting $n\to\infty$, we obtain
$$\int_0^1f^2\le\int_0^1g^2$$
since
$$\lim_{n\to\infty}\sum_{i=1}^nna_i^2=\int_0^1f^2\quad \text{and}\quad\lim_{n\to\infty}\sum_{i=1}^nnb_i^2=\int_0^1g^2,$$ which are easy to prove
because $f$ and $g$ are monotone.

Here is a minor generalization, which can be proved similarly.
Let $f,g :[0,1] \to \mathbb R$ be nonnegative decreasing functions and suppose that $\int_0^x f \le \int_0^x g$ holds for each $x \in [0,1]$. Then we have $\int_0^1 (\phi\circ f) \le \int_0^1 (\phi\circ g)$, where $\phi$ is a nonnegative increasing convex function on $\Bbb R_{\ge0}$.
