moved stuff into a math library, solved problem 12