A Mathematical Walkthrough and Discussion of the Free Energy Principle