Code for homework 5 for Computational Physics