Create Beautiful Math Homework

March 15, 2018 ยท 2 minute read

Throughout my Computer Science degree I have been doing a lot my homework in Latex. It has a steep learning curve but the results are amazing.

For my technical writing class I convinced my group to use Latex instead of Word or Google Docs. In hindsight this created a lot of extra work for me but I learned a lot about customizing a Latex document. See here for the Latex template I generated. The things I really liked about this setup was the ability to modularize the document and assign different team members a section. We then collaborated on the document using https://www.overleaf.com. Overleaf has git integration so I could edit the document on my laptop and push the changes back up to overleaf. The downside to this was that my other team members were not programmers and did not know how to use git and had to use the web interface for editing. Generating and managing the bibliography was also very easy using Bibliotex.

For my personal homework I have written a script that reads a config file for the class I am in that has data like the teacher, semester, class name and so forth and generates a new Latex project with a makefile. I have been using this system for 2 semesters and it has been working great. See homework-generator.

For my probability class this semester I have also wanted to produce graphs and charts. I have been using the python libraries matplotlib and seaborn to create awesome graphs. My homework often looks better than my textbook.

Here are some highlights of the graphs I did for my homework. The visualizations helped me see what was going on with the math.

Poisson distribution
Poisson Distribution where $$ \lambda = 10 $$ [download poisson.py]
Lognormal Distribution
Lognormal Distribution $$ f(x) = \frac{1}{\sigma x \sqrt{2 \pi}} e^{- (\ln x - \mu)^2 / 2 \sigma^2 }$$ [download lognorm.py]

Using moviepy we can create a nice video of this graph where \(\sigma\) varies over time. [download lognorm_video.py]

Normal Distribution
Normal Distribution of the Velocity of a Particle $$ f(x) = 2 \frac{mv}{\sigma \sqrt{2 \pi}} e^{- ( \frac{1}{2} mv^2 - \mu)^2 / 2 \sigma ^2} $$ [download velocity.py]
Bivariate
Plot of a Bivariate Distribution $$f_{XY}(x,y) = x e^{-x(y+1)}$$ [download bivariate.py]

And just for fun let's plot a torus and make a video out of it. [download torus.py]