Fourier coefficient of convex function On $I = [0, 2π]$ consider the function   $f : I → \mathbb{R}$ to be convex.
Define:
$$a_k\pi := \int_0^{2\pi}f(x) \cos(kx)\,dx$$
Show that the convexity of $f$ implies that $a_k ≥ 0$ when $k ≥ 1$.
Integrating by parts:
$$\left\lbrace\frac{f(x)\sin(kx)}{k}\right\rbrace_0^{2\pi} - \frac{1}{k} \int_0^{2\pi} f'(x) \sin(kx)\,dx$$
Now I have two problems:
(i) I do not know whether $f$ is continuous at the boundaries
(ii) I do not know whether $f'$ exists
For (i) and (ii) I have the following hints that I must use and cannot make any regularity assumption on $f$:
Solve (i) by proving that :
$$\lim_{\epsilon\rightarrow 0}\frac{f(2\pi-\epsilon)\sin(2\pi-\epsilon)}{k}=0 \ \ \ \ \ \lim_{\epsilon\rightarrow 0}\frac{f(\epsilon)\sin(\epsilon)}{k}=0$$
but it is not clear to me how.
For solving (ii), substitute $f'$ with the left-derivative $$f'_{-}(x):=\lim_{h\rightarrow 0}\frac{f(x+h)-f(x)}{h}$$ which should always exist (??) and by convexity, be non-decreasing.
Now to prove:
$$\int_0^{2\pi}f'_{-}(x) \sin(kx)\,dx\leq 0 \tag{$*$}$$
$$\int_0^{2\pi}f'_{-}(x) \sin(kx)\,dx =\sum_{j=0}^{y-1}\int_{\frac{2\pi j}{y}}^{\frac{2\pi (j+1)}{y}}f'_{-}(x) \sin(kx)\,dx= \sum_{j=0}^{y-1} \int_{\frac{2\pi j}{yk}}^{\frac{2\pi (j+1)}{ky}}f'_{-}(\frac{z}{k}) \frac{\sin(z)}{k}dz$$
where the last equality comes from changing variable: $z=kx$.
Now I guess that in order to prove $(*)$ I should prove that each term in the last sum is non-positive, using the fact that $f'_{-}$ is non-decreasing, but I do not see how.
Any help?
 A: Suppose $f$ is $C^2$. Integrating by parts twice
$$
\int_0^{2\pi}f(x)\cos(k\,x)\,dx=\frac{f'(2\,\pi)-f'(0)}{k^2}-\frac{1}{k^2}\int_0^{2\pi}f''(x)\cos(k\,x)\,dx.
$$
Since $f$ is convex $f''\ge0$. Then
$$
\int_0^{2\pi}f''(x)\cos(k\,x)\,dx\le\int_0^{2\pi}f''(x)\,dx=f'(2\,\pi)-f'(0).
$$
Together with the previous identity you get the desired result.
If $f$ is not $C^2$, an approximation argument should work.
A: Here is a tedious approach.
First we need to justify that $f'$ is integrable ($f'$ is defined ae.).
Since $f$ is convex it is Lipschitz on any compact interval of $(0,2 \pi)$
(see, for example, Theorem 10.4 in Rockafellar, "Convex Analysis"), and so 
is absolutely continuous. Hence it is differentiable ae. and we can write
$f(x) = f(c) + \int_c^x f'(t) dt$ for $x,c \in (0,2 \pi)$. The function $f'$
(defined ae.) is integrable on any compact interval of $(0,2 \pi)$.
In fact, the function $f'$ is integrable on $[0,2 \pi]$, but that takes more work.
Since $f$ is convex,
 if $x \in [\pi , 2 \pi]$ then
$f(x) \le ({x \over \pi}-1)f(2 \pi) + (1-({x \over \pi}-1)) f(\pi)$, in particular
$f$ is bounded above.
Choose $c \in [\pi, 2 \pi)$ such that $f'(c)$ exists, then
$f(x) = f(c) + \int_c^x (f'(t)-f'(c)) dt + f'(c)(x-c)$. Note that
$f'(t)-f'(c) \ge 0$ ae., and so
$x \mapsto \int_c^x (f'(t)-f'(c)) dt$ is non decreasing. Since it is bounded above
by $\sup_{y \in [\pi, 2 \pi]}(f(x)-f(c)-f'(c)(x-c))$ we see that
 $\lim_{x \uparrow 1} (\int_c^x (f'(t)-f'(c)) dt)$ exists and is finite.
Note that this also shows that $\lim_{x \uparrow 1} f(x)$ exists and is finite.
It follows from the monotone convergence theorem that $t \mapsto f'(t)-f'(c)$ is 
integrable on $[\pi, 2\pi]$. A similar analysis shows the same holds for
$[0,\pi]$, hence $f'$ is integrable.
If we let $f_0 = \lim_{x \downarrow 0} f(x)$, we can write
$f(x) = f_0 + \int_0^x f'(t) dt$ for any $x \in (0,2 \pi)$.
Then, using Fubini, we have
\begin{eqnarray}
\int_0^{2 \pi} f(x) \cos (kx) dx &=& \int_0^{2 \pi} (\int_{0}^x f'(t) dt) \cos (kx) dx \\
&=& \int_0^{2 \pi} (\int_{t}^x \cos (kx) dx) f'(t) dt \\
&=& -\int_0^{2 \pi} {1 \over k} \sin (kt) f'(t) dt
\end{eqnarray}
We have
\begin{eqnarray}
\int_{{i \over k}2 \pi}^{{i+1 \over k}2 \pi}  \sin (kt) f'(t) dt &=&
\int_{{i \over k}2 \pi}^{{i \over k}2 \pi+{1 \over k} \pi}  \sin (kt) f'(t) dt + \int_{{i \over k}2 \pi+{1 \over k} \pi}^{{i+1 \over k}2 \pi}  \sin (kt) f'(t) dt \\ 
&=&\int_{{i \over k}2 \pi}^{{i \over k}2 \pi+{1 \over k} \pi}  \sin (kt) f'(t) 
dt +
\int_{{i \over k}2 \pi}^{{i \over k}2 \pi+{1 \over k} \pi}  \sin (kt+\pi) f'(t+{1 \over k} \pi) dt \\
&=& \int_{{i \over k}2 \pi}^{{i \over k}2 \pi+{1 \over k} \pi}  \sin (kt) (f'(t)  - f'(t+{1 \over k} \pi)) dt
\end{eqnarray}
Since $f$ is convex, we see that $f'$ is non decreasing, it follows that the last term is non positive,
hence we see that $a_k \ge 0$.
