Math is Fast Counting

I’ve always considered myself decent at math. My arithmetic and multiplication are solid, I know my times tables, I can even do basic algebra and geometry. I remember taking calculus in school, but I didn’t retain any of that. It never seemed very practical to me, and I forgot it all.

As a programmer, I’m also very skilled at thinking through logic problems. I can figure out how to do just about anything using code.

What I am discovering though, is that math is kind of a cheat code for programmers. If you know some of the more complex aspects of math, it makes programming simpler and cleaner.

Math vs Programming #

Let's think about a contrived example, the kind that math textbooks love.

Think about the word tart. How many unique ways can you rearrange the letters?

If I were to write some code to do this, I would treat the problem literally: my code would shuffle the letters around, and compare the new example to previous examples. If it matches one, discard. Otherwise, add one to the count and add the new example to the list. This would work, and I would likely get away with it because computers are so dang fast at counting.

But this method is incredibly inefficient. It would work for this one example, but the longer the words get, the harder it is on the computer.

The word tart has twelve unique combinations of letters. Even using the program I outlined above, the computer could figure this out pretty fast. But a five letter word, such as throw has 120 combinations. A six letter word has 720 combinations. Seven letters: 5040.

As the number of letters increase, the load on the computer increases. With a seven letter word, it might take a decent computer a few seconds to work it out. But that’s only due to the inefficiencies of the code.

The computer is calculating, remembering, and counting each instance manually. This is why it is slow. But there’s a faster way to count, and it’s called math.

Welcome to math: math is fast counting.

Math is fast counting #

For some reason I always thought math was about solving problems. That’s what you see in the textbooks: problems to solve. But most of these problems are contrived, and hard to apply to real life. If you think of math as really fast counting, all of a sudden it seems more useful.

In programming, we don’t always count things, but when we do we should use math.

Math is fast counting. You can add 10+10 much more quickly than you could count to 20. Similarly, try counting to 10 x 10. Or 10^10. I dare ya.

“Math is fast counting” is honestly an idea I had never heard before, and it makes math seem much more practical to me. I was introduced to this idea by Mathew Crawford, and frankly, he’s made me interested in math again. He talks about math in an incredibly approachable way. My introduction to his style of math was this “educational math chat”, where he teaches a young girl what he considers to be the fundamentals of math. “Math is fast counting” is a decent summary of the video, but you’ll have to watch it to get into the details.

Even though I feel like I have a good foundation in math, I only knew about half of what he taught to Iris in the video above. He quickly goes deeper into certain topics than I’ve ever gone before, and makes it practical and fun. I learned a lot, and it inspired me to find more math videos from Mathew (these ones are more challenging). I feel like I’ve learned more about math in a couple of videos than I did my last couple of years of school.

Really makes you think.

← Home

Changelog
  • Adds new post on math