I am trying to optimize the number of comparison in the merge sort algorithm, particularly during the merging step.
Is $a\log_2(b) \le b\log_2(a)$ for all $a$ and $b$ given that $1 \le b \le a$?
I plugged values of $a=2$ and $b=1$ and $2\log(1) \le 1\log(2)$ is true because $0\le1$, but I don't believe this is enough proof. Are there some values of $a$ and $b$ where this is not true?
if that is true, how to prove it mathematically ?
In most cases, the reverse inequality holds.
The inequality $a \log_2 b \le b \log_2 a$ is equivalent to $\frac a{\log_2 a} \le \frac{b}{\log_2 b}$, so we should look at the function $f(x) = \frac{x}{\log_2 x}$,
The derivative of $f(x)$ is $f'(x) = \frac{\log_2 x - \frac1{\ln 2}}{(\log_2 x)^2}$, or $\frac{\log_2 (x/e)}{(\log_2 x)^2}$. This is positive when $x>e$, and negative when $x<e$.
I will assume $a,b$ are integers. Then if $3 \le b \le a$, we have $f(b) \le f(a)$ because $f$ is increasing on this range, so in fact the reverse inequality holds: $a \log_2 b \ge b \log_2 a$.
We can check the remaining cases separately: