Re-visiting an inequality problem involving convexity This question is in link with the following question: An Inequality Problem Involving Convexity : that I already asked in math.stackexchange a few weeks back.  Lee David Chung Lin gave a very nice counterexample to that question, which was indeed extremely helpful. However, I added a comment there, to which I did not get a reply from anyone yet. In this post, I ask for a specialized (and probably somewhat easier) version of my original question in that comment.
So, here I define a function $f(x) = x \log x + (1-x) \log (1-x)$ for $x \in [0,1]$ (with the obbvious convention that $0 \log 0 = 0$). Suppose that $x_1, x_2 \in [0,1]$, and I define $$\bar{x} = \sqrt{\frac{x_1^2 + x_2^2}{2}}~.$$ Then, I strongly suspect that the following inequality holds:
$$f(x_1) + f(x_2) \geq 2 f(\bar{x})~,$$ and further, equality holds if and only if $x_1 = x_2$. Can someone help me prove this inequality, or give a counterexample, if possible? I have checked this inequality using a very fine mesh of $[0,1]^2$ in MATLAB, and so, I believe that this inequality is indeed true.
Any help will be highly appreciated.
 A: If you do a substitution, $y = x^2$, then
\begin{equation*}
 \bar y = \bar x^2 = \frac{x_1^2+x_2^2}2 = \frac{y_1+y_2}2.
\end{equation*}
Thus, your question is equivalent to asking about convexity (w.r.t. $y$)
of the function
\begin{equation*}
 g(y)
 =
 \sqrt{y}\,\log\sqrt{y}
 +
 (1-\sqrt{y})\,\log(1-\sqrt{y})
 .
\end{equation*}
This should be answered by taking second derivatives.
Similarly, you can attack your original question by looking at
\begin{equation*}
 g_p(y)
 =
 \sqrt{y}\,\log\frac{\sqrt{y}}{p}
 +
 (1-\sqrt{y})\,\log\frac{1-\sqrt{y}}{1-p}
 .
\end{equation*}
For a quick check, I used MATLAB and found that $g$ is convex,
while $g_p$ fails to be convex for all $p$ smaller than something like $0.12$.
A: This is an elaboration on the answer given by gerw:
Define
$$
y_1=x_1^2\\
y_2=x_2^2
$$
and the function $g(y)=f(\sqrt{y})$. Then
$$
f(x_1)=g(y_1)\\
f(x_2)=g(y_2)\\
f(\overline{x})=g\left(\frac{y_1+y_2}{2}\right)
$$
Then the inequality is simply expressing the convexity of $g$ wrt. $y$:
$$
f(x_1)+f(x_2)\geq 2f(\overline{x})\\
\Updownarrow\\
\frac{g(y_1)+g(y_2)}2\geq g\left(\frac{y_1+y_2}{2}\right)
$$

So let us define $f$ a bit more generally as related to your original question:
$$
f(x)=x\log\left(\frac xa\right)+(1-x)\log\left(\frac{1-x}b\right)
$$
still keeping the definition $g(y)=f(\sqrt y)$. To find the derivatives of $g$ in order to possibly show convexity (depending on $a,b$) we may break this into parts applying the chain rule a couple of times:
$$
\left(x\log\left(\frac xa\right)\right)'=\log\left(\frac xa\right)+1
$$
which by applying the chain rule and $(1-x)'=-1$ gives us
$$
\left((1-x)\log\left(\frac{1-x}b\right)\right)'=-\log\left(\frac{1-x}b\right)-1
$$
showing that
$$
f'(x)=\log\left(\frac xa\right)-\log\left(\frac{1-x}b\right)
$$
and since $(\sqrt y)'=1/(2\sqrt y)$ this gives us
$$
g'(y)=\frac{\log\left(\frac{\sqrt{y}}a\right)-\log\left(\frac{1-\sqrt{y}}b\right)}{2\sqrt{y}}
$$

Now to find the second derivative, let us then consider the function
$$
h(x)=\frac{\log\left(\frac{x}a\right)-\log\left(\frac{1-x}b\right)}{2x}
$$
and the derivatives of the subexpressions:
$$
\left(\log\left(\frac xa\right)\right)'=\frac 1x\\
\left(-\log\left(\frac{1-x}b\right)\right)'=\frac 1{1-x}\\
\left(2x\right)'=2
$$
implying
$$
h'(x)=\frac{\left(\frac1x+\frac1{1-x}\right)\cdot 2x-\left(\log\left(\frac{x}a\right)-\log\left(\frac{1-x}b\right)\right)\cdot 2}{(2x)^2}
$$
And so finally, we can conclude that $g''(y)=\left(h(\sqrt{y})\right)'=h'(\sqrt y)/(2\sqrt y)$ which then is
$$
g''(y)=\frac{\left(\frac1{\sqrt y}+\frac1{1-\sqrt y}\right)\cdot 2\sqrt y-\left(\log\left(\frac{\sqrt y}a\right)-\log\left(\frac{1-\sqrt y}b\right)\right)\cdot 2}{(2\sqrt y)^3}
$$

Finally, coming back to gerw's answer, to see whether $g$ is convex so that the inequality holds for $f$, we must check whether $g''$ is non-negative in $(0,1)$. In fact we do not have to check this for $g''$ but can work with $h'$ since those two share signs. Furthermore, only the numerator affects the sign of the expression. We can also remove the shared factor $2$ and simplify:
$$
\left(\frac1x+\frac1{1-x}\right)\cdot x=\frac{1}{1-x}
$$
and apply logarithmic rules to draw out $a,b$ and recombine. Then $h'(x)\geq 0$ can be seen to be equivalent to:
$$
q(x)=\frac1{1-x}+\log(1-x)-\log(x)+\log(a/b)
\geq 0
$$
By taking the derivative of $q$:
$$
q'(x)=\frac 1{(1-x)^2}-\frac1{1-x}-\frac 1x=\frac{2x-1}{x(1-x)^2}
$$
we see that $q$ has its minimum at $x=0.5$. One can check that $q(0.5)=2+\log(a/b)$ which implies that $q$ is non-negative as long as
$$
\log(a/b)\geq -2\\
\Updownarrow\\
\frac ab\geq \operatorname e^{-2}
$$

Going back to the original problem in this question $a=b=1$ so in this case $g$ is convex and the original inequality works. In the other post you wanted:
$$
a=p\\
b=1-p
$$
so the requirement becomes
$$
\frac p{1-p}\geq \operatorname e^{-2}\\
\Updownarrow\\
p\geq\frac{\operatorname e^{-2}}{1+\operatorname e^{-2}}=\frac{1}{\operatorname e^2+1}\approx 0.1192029220
$$
The last part is of course assuming $p>0$ for otherwise the inequality will be reversed, and/or the function $f$ will be ill-defined.
