Using the 'Sandwich Method' to Teach Mathematics

I receive a lot of messages from students asking me if I have plans of recording a "Math for Computer Science" or a "Math for Games" course for the school website. I have thought about this for a long time, and I'm inclined to say it won't happen… at least, not as most you'd expect.

math for game developers

When people email me asking if I'll ever create a "Math for Programmers" course, they are usually looking for a resource that exposes a linear sequence of math topics that are widely used in games or computer science.

One of the main reasons I probably won't create something in this format is simply because there are already too many great books and online resources that give students exactly that! And to be fair, even if my teaching style was superior, the topics and the exercises would not be too different than what these resources already offer.

A few examples of great resources that follow this method of linearly listing topics are 3D Math Primer for Graphics & GameDev (by Fletched Dunn), or Basic Math for GameDev with Unity3D (by Kevin Sung & Gregory Smith), or even FGED: Mathematics (by Eric Langyel). I always recommend these resources to students in my lectures anyway; they are great and will present a list of important math topics with different levels of rigor and depth.

So, if you simply want a list of topics on 'Math for Games' or Math for Programmers', there is no lack of resources with formulas and derivations from the popular math you use in CS & gamedev. That being said, this is not what I usually do in my courses, and I don't think I'll use this format anytime soon.

So, What Is My Teaching Approach?

Ever since I started recording my lectures, the approach I have been using in all my courses is very free and fluid. The topics and the areas are almost never linear.

Sometimes we start looking at a computer science problem, but soon we find ourselves learning concepts of mathematics, then we end up looking at physics, then a little bit of chemistry shows up, and to connect everything and make sense of this unorthodox learning path we need to look back and learn from history too.

The boundaries are not clear and to actually absorb the topics we end up touching multiple areas of knowledge.

subject overlap
Subjects often overlap and we end up touching many areas of knowledge.

This has everything to do with what I researched during my master's degree, years ago. My thesis was on how game programming can be used to enhance awareness of mathematics, where I wrote and gave many talks about a technique I like to call the “sandwich method.”

sandwich method conference talk
Presenting the benefits of using the 'sandwich method' to teach math at the TPEA Conference.

The Sandwich Method

To understand why I call it the "sandwich method", I need to explain a few things first.

I grew up in the south of Brazil, in a corner of the world where the culture is a mix of different flavors of gauchos from Brazil, Uruguay, and Argentina. As most of you already know, our diet there is heavily based on meat.

gaucho
Heavy caddle gaucho culture in the pampas.

As a kid, I always loved everything meat and I hated salad.

Problem: So, how do you make a kid that hates salad eat salad?

Solution: My mom used to hide lettuce leaves inside my sandwiches. I was so happy eating a tasty meat sandwich that I didn't even notice that nutritious lettuce between the many layers of stacked meat and cheese.

math sandwich method
Hiding nutritious salad inside layers of tasty meat and cheese.

I apologize for the corny analogy, but you probably know where I'm going with this. I found out that one of the most effective ways of teaching mathematics to a generation of adults that was raised to hate the discipline is to "hide" bits of math between layers of other topics that students are already motivated to learn.

Let's say you want to start learning more about linear algebra and understand some of its applications in game development. You should consider coding a simple programming project that contains some applications of linear algebra in it. It can be a coding project that you are already motivated to complete (that's your sandwich), and the linear algebra required for the game to work correctly is collateral (that's your salad).

pacman math gamedev
We "hide" the math inside a coding project that students are already motivated to pursue.

You know it's good for you. All you need is some help digesting it.