Yesterday, nobody contributed anything. :-(
The official answer is:
log2(floor(2 * x * (x - 1) ^ 2) / x)