I want to find the Legendre Transform of $$T(f) = \int_{\mathbb{R}^2} f \log \left(\frac{f}g{}\right) \, dx$$ on a set $H_M = \{ f: f \ge 0 \text{ and } \int_{\mathbb{R}^2} f =M\}$, where g is some function in $H_M$.
i.e. finding $T^*(u) = \sup_{f\in H_M} (\int_{\mathbb{R}^2} uf\, dx -T(f))$.
The answer seems to be $T^*(u) = M \log (\frac{1}{M}\int_{\mathbb{R}^2} e^u g\, dx) - M\log M$. But I have trouble in getting that. Can anyone show me how to get this result? Thanks!!