Code and plot for the first exercise.