Code for Section 4.

Code discussed in Section 4 of tutorial.