Chapter 3 almost written. Energy functions explained