Source: http://www0.cs.ucl.ac.uk/staff/S.Arridge/teaching/optimisation/EX1/ex1_Hints.pdf