How would I minimise this sum?

42 Views Asked by At

The sum I would like to minimise is

$$f(a)= \sum^n_i a_i\log_2 a_i $$

on the constraint that $a_i \in (0,1]$. If I take the gradient of this function with respect to each $a_i$ I obtain $$a_i=e^{-1}.$$

This problem stems from not being able to understand a problem in a textbook of mine, which says that

$$g(a) = \sum^n_i a_i\log_2 (1/a_i)$$

is maximised when all $a_i$ are equal (under the constraint that a_i represent probabilities). Am i correct in saying that maximising $g$ is the same as minimising $f$?