The relation between magnitude and energy of earthquakes