I get this solving a problem of information theory, this is of the entropy of $H(\frac{x}{2})$.
I know the result is $$\frac12 \log_2 \left(\frac {1-x/2}{x/2}\right)~.$$
But I don't get it.
I don't know what I'm doing wrong but I have this:
$$ - \left[ \frac{1}{2} \left( \log_2(x)-1\right) + \frac{x}{2}\left(\frac{1}{ \ln(2)x}\right) -\frac{1}{2} \bigl( \log_2(2-x)-1 \bigr) + \bigl( \frac{x}2 - 1 \bigr)\left(\frac{1}{ \ln(2)(2-x)}-1 \right) \right]$$
It is worth considering the differentiation of the general case $$\frac{d}{dz}\left[z \log_2 z\right] = \left(1 \cdot \log_2 z \right) + \left( z \cdot \frac{1}{z} \cdot \frac{1}{\log 2} \right) = \log_2 z + \frac{1}{\log 2}.$$ Consequently, with $z = x/2$, we have $$\frac{d}{dx} \left[\frac{x}{2} \log_2 \frac{x}{2}\right] = \left(\log_2 \frac{x}{2} + \frac{1}{\log 2}\right) \frac{d}{dx}\left[\frac{x}{2}\right] = \frac{1}{2} \left( \log_2 \frac{x}{2} + \frac{1}{\log 2} \right),$$ and similarly, with $z = 1 - \frac{x}{2}$, $$\frac{d}{dx}\left[\left(1 - \frac{x}{2}\right) \log_2 \left(1 - \frac{x}{2}\right) \right] = -\frac{1}{2}\left(\log_2 \left( 1 - \frac{x}{2} \right) + \frac{1}{\log 2} \right).$$ It follows that $$\frac{d}{dx} \left[-\frac{x}{2}\log_2 \frac{x}{2} - \left(1 - \frac{x}{2}\right)\log_2 \left(1 - \frac{x}{2}\right) \right] = -\frac{1}{2} \log_2 \frac{x}{2} + \frac{1}{2} \log_2 \left(1 - \frac{x}{2}\right). $$ Note the constants cancel out. This is further simplified to $$\frac{1}{2} \log_2 \frac{1 - x/2}{x/2}$$ as claimed.