See the pdf for notes.