Initial solution to problem 2

I've included a theory.txt file which shows the mathematical theory behind my
solution.