Learning Math for Programming

When I went to college I had to take math. My degree is actually in Math and Computer Science. Why the math part, you ask? Well, the folks at the school figured that the math will help with a lot of the logic that comes with programming.

Of course, there's also that age old question when you first start learning programming...is there a lot of math involved? The answer is it depends. If you're planning to get a doctorate and do a lot of research, then you'll most likely use a lot of it. However, if you're just working for a company, then chances are you won't need hardly any math*. If you're learning data science then some math is essential in order to gain insights from data or to understand machine learning algorithms.

In this post, we'll go over the most common types of math you may want to be familiar with to get the most out of your programming, and where you can start learning these concepts.

Discrete Math

Discrete math is used quite a bit in programming. Whether it's understanding the theory of how integers work in programming languages or using boolean logic, you've probably come across it before.

Where to Learn

Coursera comes to the rescue here as there may not be too much around discrete math.

Algebra

Yep, even plain old algebra you probably didn't like in high school can be helpful. I actually have an example of this: back when I was doing tax software I needed to use some basic algebra to create a function. Of course, tax software relies heavier on math than most other software, so it's not unusual. Knowing that bit of algebra that I needed, though, really helped when creating the function and I may have had to spend a good bit of time Googling for some help.

Where to Learn

Kahn Academy is well known for their math courses and they definitely have a good algebra one.

For a book, Practical Algebra looks to be a good one to brush back up on your algebra.

Statistics

Statistics is needed for data scientists, not only to help get insights from your data but to also make sure variables that seem correlated to each other actually are statistically significat rather than not. That's not the easiest to do even if you plot your data. Statistics will give you a big advantage in understanding your data and how it can answer any questions you can throw at your data.

Need to see if an A/B test has a significant difference? Then statistical hypothesis testing can be of a great help.

Where to Learn

Coursera has a great intro to data course that has really helped me out in learning some of the basics of statistics. The book they recommend, too, is actually really good.

As for books, I recommend a couple to start with. Practical Statistics is a great introduction. If you want to focus more on the data science side of statistics then Practical Statistics for Data Scientists is a great one to get.

If you want to get a bit advanced, then I definitely recommend Introduction to Statistical Learning. This is mainly for getting deep in the machine learning algorithms, but still is an interesting read. You can also read it for free online instead of getting a physical copy. There's an even more advanced version of this too with The Elements of Statistical Learning, which is also available for free online.

Linear Algebra

Linear algebra is a bit of a niche in programming. The only place I've really seen it used is for machine learning algorithms. Linear algebra, is mainly matrix manipulation.

Where to Learn

Khan Academy has some linear algebra courses that you can take. This is probably the most complete of them I've seen around.

For a book, mostly what you'll see are text books. That's not all bad, but sometimes a more general book is helpful. In that case there's Linear Algebra for Dummies.


While math isn't necessary for programming, I believe it can certainly help with the logic like my university thought. Learning the extra math also made me appreciate it more for what all math can teach us about the world. Also, don't think you're not good at math. This old post from Steve Yegge explains more about the way math is taught in schools and what we can do about it as programmers. You're not bad at math, you just need a better way to learn it.

* Though, depending on the company you work for you may need it. For example, working for a financial institution may involve some knowledge of math.