I’ve come to be somewhat known as a “math guy” in creative coding. It’s one of my impostor syndrome items because I’m really not any kind of expert in the field. I took Algebra and some Precalculus in high school banged my head on a formal Calculus course, but never made it through. Most of what I know has been self-taught and pretty seat-of-the-pants.
I’m pretty good at fumbling my way through things, figuring out intuitively how things work to the point where I can use them pretty expertly to do what I need to do with them, but I could not hold my own in a conversation with anyone who has a real math background. For a while now I’ve wanted to shore up that shaky wall of knowledge.
Recently I stumbled upon this book, A Programmer’s Introduction to Mathematics at https://pimbook.org/. There you can read a chunk of the first part of the book, buy a hard copy or an ebook version. If you go for the ebook, you can pay what you want. I paid $0 for a copy in order to evaluate it. But before I even got through Chapter 1, I went back and paid a decent amount for another copy in order to support the author.
As the title implies, the book is targeted towards programmers who do not have an academic math background. One thing that resonated with me right off is that the author talks about the language of mathematics as an analogy to the language of programming, and how when you were starting to code, everything was confusing, but you probably stuck with it and now it makes sense. Math is the same way, but for some reason, a lot of programmers tend have less patience when studying math.
He also discusses the fact that the language of mathematics is looser than programming in a lot of ways. In code, things have to be expressed a very exact way or they just don’t compile. Variables and functions have to be fully and explicitly defined if you expect the computer to run them. But in math, there’s a lot of tacit agreement and assumptions that go on. Lots of shortcuts and conventions. So if you’re not steeped in that culture, it all looks like black magic to you. This is exactly what I’ve experienced over the years. The text will talk vaguely about an idea and then there will be a formula with all kinds of Greek letters, and no explanation of what those symbols mean. If you aren’t already familiar with them, you don’t stand a chance.
Some of the topics covered in the book:
- Polynomials
- Sets
- Graphs
- Calculus with one variable
- Linear algebra
- Eigenvectors and Eigenvalues
- Multivariable calculus
- Groups
Chapter 1 talks about polynomials and how formulate a polynomial that will pass through a series of points. The author goes through the concepts and definitions and the strategy on how to solve it, ending up with a few proofs. And you get to the following formula:
By the time I got there, I actually fully understood that formula! This felt really good. From there, the chapter went into a code example (all written in Python). But I felt so confident, I went straight in and coded up my own example in Golang. I defined a set of points, generated the polynomial for that set of points and then drew the curve based on that polynomial, and what do you know? It went through all the points, just as expected.
I was even able to animate it!
After finishing Chapter 1, I was checking into a subject that I’ve been aware of since the 90’s but had never actually tried to code: Lyapunov fractals. Heading to wikipedia’s page on the subject – https://en.wikipedia.org/wiki/Lyapunov_fractal – I came across this formula:
This looked pretty daunting. In the past I would have looked at that and glazed over. But this time I was able to read the formula and understand what was going on there. It wasn’t bad at all. I wrote the code solely based on what you see above (and a related function r in the same article) and was able to create this:
It took a while to get the coloring algorithm down, but the formula worked perfectly on first compile.
I’m on to chapter 2 now, which is all about sets. Lots of definitions so far, but it’s all making sense. I’m really looking forward to getting through the rest of the book and giving myself a more solid foundation in math.
If you don’t have a formal mathematics education, or need to brush up on what you do have, I highly recommend this book.
Glad to hear you’re enjoying the book! Feel free to drop any questions on the book text or exercises at https://github.com/pim-book/exercises (I know some of the exercises are a bit intense!)
Hi! I discovered your post on Hackernews! I have a similar profile as yours, better at programming than math. Grabbing things by intuition, but not enough math cultural foundations to delve deeper in the details.
I want to say thank you for making us discover this book. Buying it right now.
Quick question: What did you use to paint – so to speak – the Lypunov fractal?
Thank you
Alex
HI! I just came across with your post, and it was exactly what I needed. I am getting to know machine learning, and I just purchased the book Applied Machine Learning, and it has a lot of math. I just don’t understand the formulas. I was very good with algebra in High School, but I got lost in Calculus at college. I really was a mess. But I am confident in this book that you recommend. I’ve already ordered it in Amazon. Arriving on monday.. Thank you!
Nice hint. Thx Keith (<- as if I know you, but sounds better as Mr. Peters)
With a little humor too, the '2 for t' in the beginning ?
It's also a fun coincidence that just yesterday (aug. 19) "World Sience festival" released on YouTube "Does Math Reveal Reality?"
Fun to listen if you have an hour, even if the book is about Math creating Reality. A bit philosophical it is, and a bit of history on how math describes and thereby can create reality
Great book but needs answers to exercises to be much use for self-learners, IMO. The math is not simple, and consolidation of each concept through trying exercises and seeing correct solutions is needed to make much headway, IMO. It seems like a lost opportunity to me, not to have the solutions. Without them, the book is more use as entertainment for people who already mostly understand the material than as a resource for self-learners, IMO.