On the Legendre transformation