(Putnam) Let $f:[1,3] \rightarrow \mathbb{R}$ such that $-1 \leq f(x) \leq 1 $ for all x and The following is a Putnam math competition problem:

Let $f:[1,3] \rightarrow \mathbb{R}$ such that $-1 \leq f(x) \leq 1 $ for all x and $ \int_{1}^{3}f(x)dx = 0 $. What is the max value of $\int_{1}^{3} \frac{f(x)}{x}dx$ ?

What I did:
$$\int_{1}^{3} \frac{f(x)}{x}dx \leq \int_{1}^{3} \frac1x dx = \log(3) $$
if we define $g(x) = f(x) + 1$ then $0\leq g(x) \leq 2$ and:
$$\int_{1}^{3}g(x)dx = 2$$
$$\int_{1}^{3}\frac{f(x)}xdx = \int_{1}^{3} \frac{g(x)-1}{x}dx = \frac{\int_{1}^{3}g(x)dx}{c} - \log(3)$$
with $c \in (1,3)$ so the max value is on the interval $[\frac23 - \log(3), \log(3)]$
I thought about using $g_n(x) = f(x) + x^{n}$ and try to make a better lower bound, but I don't think this will help much to find the exact maximum value
 A: Intuitively speaking, you are putting "mass" along the line $[1,3]$ such that the total mass is zero, and the density at any point must only be between $1$ and $-1$. Since you are trying to maximize the value of $\int_1^3 f(x) / x \; dx$, mass closer to $1$ is weighted higher and mass closer to $3$ is weighted lower. So you should put as much mass as possible close to $1$, which means the optimal function will be $1$ on the interval $[1,2]$ and $-1$ on the interval $[2,3]$.
Rigorous argument: Based on the above intuition, let
$$
g(x) := \begin{cases} 1 & \text{if } 1 \le x \le 2 \\ -1 & \text{if } 2 \le x \le 3 \end{cases}
$$
We wish to show that for any $f : [1,3] \to [-1,1]$ with integral $0$, $\int_1^3 f(x) / x \; dx \le \int_1^3 g(x) / x \; dx$. To prove this, take the difference :
\begin{align*}
\int_1^3 \frac{g(x)}{x} \; dx - \int_1^3 \frac{f(x)}{x} \; dx
&= \int_1^3 \frac{g(x) - f(x)}{x} \; dx \\
&= \int_1^2 \frac{g(x) - f(x)}{x} \; dx
+ \int_2^3 \frac{g(x) - f(x)}{x} \; dx \\
&= \int_1^2 \frac{1 - f(x)}{x} \; dx
+ \int_2^3 \frac{-1 - f(x)}{x} \; dx \\
&= \int_1^2 \frac{1 - f(x)}{x} \; dx
- \int_2^3 \frac{1 + f(x)}{x} \; dx \\
&\ge \int_1^2 \frac{1 - f(x)}{2} \; dx
- \int_2^3 \frac{1 + f(x)}{2} \; dx \text{ (both integrands were positive)}\\
&= \frac12\left[1 - \int_1^2 f(x) \; dx \right]
- \frac12 \left[1 + \int_2^3 f(x) \; dx \right] \\
&= 0 - \int_1^3 f(x) \; dx \\
&= 0.
\end{align*}
A: Let $E=[1,3]$. Assume $f:E\to[0,2]$ is Riemann integrable with $\int_E f=1$. Let $P_n$ be the partition $1,1+\frac1{2n},...,3$ of $E$, then the upper Darboux sum for $f$ is:
$$U(f,P_n)=\sum_i b_i\frac1{2n}\geq \int_E f(x)dx=1$$
Then
$$\sum_i \frac{b_i}{1+\frac i{2n}}\frac1{2n}\geq\sum_i (\sup_{t\in [1+\frac i{2n},1+\frac{i+1}{2n}]}\frac{f(t)}t)\frac1{2n}=U(\frac{f(x)}{x},P_n)\geq\int_E\frac{f(x)}xdx$$
Suppose $U(f,P_n)=1+\epsilon$. Then
$$\sum_i \frac{b_i}{1+\frac i{2n}}\frac1{2n}$$
$$=\sum_{i=0}^{n-1} \frac{b_i}{2n+i}+\sum_{i=n}^{2n-1} \frac{b_i}{2n+i}$$
$$=\sum_{i=n}^{2n-1} \frac{b_i}{2n+i}-(\sum_{i=0}^{n-1} \frac{2-b_i}{2n+i})+\sum_{i=0}^{n-1} \frac{2}{2n+i}$$
$$\leq \sum_{i=n}^{2n-1} \frac{b_i}{2n}-(\sum_{i=0}^{n-1} \frac{2-b_i}{2n})+\sum_{i=0}^{n-1} \frac{2}{2n+i}$$
$$=\sum_{i=0}^{2n-1} \frac{b_i}{2n}-\sum_{i=0}^{n-1} \frac{2}{2n}+\sum_{i=0}^{n-1} \frac{2}{2n+i}$$
$$=(1+\epsilon)-1+\sum_{i=0}^{n-1} \frac{2}{2n+i}$$
$$=\epsilon+\sum_{i=0}^{n-1} \frac{2}{1+\frac i{2n}}\frac1{2n}$$
$$=\epsilon+U(\frac{g(x)}x,P_n)$$
where $g(x) = \begin{cases} 2 & \text{if } 1 \le x \le 2 \\ 0 & \text{if } 2 \le x \le 3 \end{cases}$
Therefore
$$\int_E\frac{f(x)}xdx\leq U(\frac{g(x)}x,P_n)+\epsilon$$
When $n\to\infty$, we get $\epsilon\to0$ and the RHS becomes
$$\int_E \frac{g(x)}xdx=\int_1^2 \frac2xdx=\log4$$
Conversely, $g$ satisfies the conditions of $f$ so the maximum is attainable.
Transforming back to the original range, the maximum is 
$$\int_1^3 \frac{g(x)-1}xdx=\log4-\log3$$
