from Hacker News

A Programmer's Introduction to Mathematics

by chocolateboy on 12/1/18, 9:31 PM with 214 comments

  • by threwythrw on 12/1/18, 11:47 PM

    Do the exercises have solutions? The most annoying things about math books is the lack of solutions. A beginner absolutely needs to know whether or not their solutions are correct.

    The “the reader should know if they are correct” logic doesn’t apply here. A beginner could easily have faulty logic and fool themselves into thinking their solutions are correct.

    I usually don’t buy math books without solutions if I’m self-studying. Would like to know if solutions are provided in this book. If not, I won’t consider buying it.

    If this book doesn’t make the cut with a solution manual, does anyone have recommendations on an intro to proofs book with one?

  • by mlejva on 12/2/18, 9:49 AM

    I have a genuine question which might sound dumb but I really do wonder.

    How do you actually read math, physics and programming books?

    Reading them the same way as you'd read a novel doesn't seem right. I try to go chapter after chapter and make notes but I often get bored because I don't see the usage in my real life coding. Maybe I'm not working on problems that are challenging enough? Also after few chapters it often turns into a "job" of finishing the book. I don't have the pleasure of learning new stuff anymore.

    Do you really finish such books? What am I doing wrong?

  • by sjroot on 12/1/18, 11:32 PM

    As someone who works as a programmer but wasn’t super interested in mathematics, I’ve found this blog to be a fantastic read time and time again. I’d highly recommend going through Jeremy’s previous posts if this is your first time seeing his site on here.

    If this topic piques your interest I would also recommend Mathematics for Computer Science: https://courses.csail.mit.edu/6.042/spring17/mcs.pdf

  • by _Nat_ on 12/2/18, 3:50 AM

    To the author:

    You might want to extend the preview PDF to include a few pages from later chapters. The issue's that the [current preview](https://pimbook.org/pdf/pim_first_pages.pdf) only gets into polynomials over its 45 pages. But since polynomials are typically taught to students during early childhood, it seems like most readers are liable to just skim that content, being more interested in the topics discussed later. For example, the start of Chapter 14 (on optimization) would be neat to see.

    That said, I like the parts that translate between analytical expressions and programming code. Such mappings seem like high-value content to readers; the language barrier can keep people from understanding mathematical writing, while a few helpful translations can help to tear down those language barriers.

  • by alan_wade on 12/2/18, 2:38 AM

    I really wish this book would include probability and statistic sections. My guess is that a lot of people, like me, will want to read it because they're getting started with ML and need help getting used to the math, and probability/stats is an important part of it that's missing.

    Any chance you could add it in the future?

  • by Koshkin on 12/1/18, 11:09 PM

    It's good to have something that lowers the bar for programmers so they could learn themselves some math without much fear. Knowing math is very important if you are a coder - and not just linear algebra: knowing a formula, for example, might let you do certain things in constant rather than linear time or, perhaps, reduce the cost of the iteration. Unfortunately, too many of those who can call themselves programmers by trade know very little math (you'd be lucky if they remember what they learned in high school).
  • by EGreg on 12/2/18, 8:41 AM

    I was teaching a college class for high schoolers last year and thought it would be great to record my lectures for them. Then I put it up as an entire youtube channel for everyone:

    https://m.youtube.com/channel/UCuge8p-oYsKSU0rDMy7jJlA

    It basically builds up mathematics rigorously from basic definitions, while trying to stay very accessible.

    If anyone has the time, or desire to learn math this way, let me know what you think, and if I should make more in this series!

  • by yantrams on 12/2/18, 3:19 AM

    I am a huge fan of Jeremy's blog. Found his primers on a multitude of topics very useful - https://jeremykun.com/primers/

    As a Math guy who got into the world of programming relatively recently, I am on the opposite side of the spectrum I suppose but I'm gonna order this nonetheless to support him.

  • by aargh_aargh on 12/1/18, 11:20 PM

    Hmm, the "first few pages" end just before the "meat" begins.

    From the table of contents, there seem to be short prose sections inteleaved with the teaching sections. I hoped to see an example of the teaching section, not the prose.

  • by bootsz on 12/2/18, 12:31 PM

    > The problem is that the culture of mathematics and the culture of mathematics education--elementary through lower-level college courses--are completely different ... I've had many conversations with such students [...] who by their third year decided they didn't really enjoy math. The story often goes like this: a student who was good at math in high school (perhaps because of its rigid structure) reaches the point of a math major at which they must read and write proofs in earnest. It requires an earnest, open-ended exploration they don't enjoy.

    I found this interesting because I too discovered this difference in approach but had the complete opposite reaction. I absolutely hated math in middle and high school. It wasn't until I took a discrete math course for my CS program that I got exposed to dealing with real proofs, which I found required a level of creative thinking, and I totally loved it. This admittedly wasn't an "advanced" university math class, but the difference from high school math was still quite stark.

  • by mkagenius on 12/2/18, 6:33 AM

    Nice.

    I tried to start something similar which tried to explain all weird maths symbol via code. It went nowhere.

    But feel free to check https://github.com/mkagenius/mathsymbol2code

  • by newnewpdro on 12/1/18, 11:36 PM

    What's provided currently at [1] doesn't provide the reader with any impression of the teaching style or quality/quantity of visual aids.

    I'm very likely to buy a hard copy of such a book, but not unless I can do the equivalent of flipping through it like I would in a book store.

    Consider changing the preview instead to a scattered sampling of some of your proudest pages.

    [1] https://pimbook.org/pdf/pim_first_pages.pdf

  • by jamestimmins on 12/1/18, 11:44 PM

    On a related note, I'm curious if anyone has taken the Mathematics for Machine Learning (https://www.coursera.org/specializations/mathematics-machine...) courses on Coursera, and whether it really covers enough to be comfortable with ML. The course bills itself as enough math knowledge for folks who barely remember high school math.
  • by armatav on 12/2/18, 4:21 AM

    Can we get that GitHub solutions repo going? I feel like that's super important for this book. Bought it anyway.
  • by baron816 on 12/1/18, 11:57 PM

    I’ve found myself unable to do even elementary maths recently just because I’m sorely out of practice. Hasn’t really affected my performance as a programmer. Wondering, what kind of math I could learn that would benefit me in my job?
  • by beefsack on 12/2/18, 1:16 AM

    It appears the ebook is in PDF format[1], does anyone know if an EPUB will become available?

    [1]: https://gumroad.com/l/pim-book

  • by mrcartmenes on 12/1/18, 11:02 PM

    It’s a shame you don’t get to read any of the actual maths in the sample pages. Otherwise I might have been able to evaluate whether I want to buy this book. Intros don’t really tell us much
  • by febin on 12/1/18, 11:08 PM

    I have been searching for something like this for a while. Just bought the book, I will get back to you. I hope the book will give me exactly what it promises.
  • by oblib on 12/1/18, 10:41 PM

    I've been wanting to peek into mathematics and an "introduction" is exactly what I need.

    Thank you for sharing this.

  • by madhadron on 12/2/18, 7:29 PM

    I would be interested to see someone post their experiences after working through at least half of the book. I am completely outside the target audience, and it would be really useful to know what works to teach mathematics to programmers and what doesn't.
  • by dhodges on 12/3/18, 10:35 PM

    Long-time programmer without a CS degree here. I've studied polynomial factoring, adding, subtracting, graphing them, etc. Sites like Khan Academy break things down in little bits but the underlying theory seldom emerges. But after working through the preview pages of this book I feel like I finally have a feel for some of the underlying theory ideas behind polynomials. This really emerged during the proofs section. The bits of code and analogies to programming really help. It was like a lightbulb going off in my brain. As a result I have ordered the book from Amazon and can't wait for it to arrive. Thank you for this book.
  • by bwobst on 12/2/18, 4:35 AM

    I recently started reviewing mathematics on Khan Academy to brush up on my math skills and learn more Calculus so I can better understand ML. Really looking forward to reading this!
  • by paultopia on 12/2/18, 12:02 AM

    This looks really nice, from the preview content---I really like the approach of explaining the background assumptions of reading mathematical definitions and such. Ordered!
  • by Sniffnoy on 12/2/18, 10:17 AM

    Some comments/corrections on the first chapter, if you don't mind:

    1. Theorem 2.4 is stated incorrectly. Given the context, I feel like this is worth correcting. Specifically, it says "degree n" rather than "degree at most n". Part of the proof purports to prove that the degree is indeed n but of course it doesn't because that needn't be true.

    There are other cases where you say "degree n" for "degree at most n". Again usually this would be a minor error not worth pointing out, but in this context it seems worth getting right.

    2. At one point you introduce a convention that deg(0)=-1. Later, in the exercises, you ask, is this really such a good convention? (The answer being, of course, no.) IMO you should anticipate this. Indeed I don't think you should state, as you do, "By convention the zero polynomial is defined to have degree -1", because that suggests it's some standard universal convention, which is definitely correct, and it's neither of those. Rather you should say something like "We'll use the convention that the zero polynomial is defined to have degree -1". But anyway, the point I made is that, if you're going to question its correctness later, you should anticipate that here, maybe saying something like "(Think about whether this convention makes sense.)" Or maybe not, and just getting rid of the absolutism of your current wording is sufficient. Either way, getting rid of that absolutism and certainty is good; you want to encourage to people about this sort of thing immediately, not encourage them not to think about it until later.

    3. You say that when you see a definition you should write down examples. I would add, "and non-examples". Ideally non-examples that come as close as possible but don't quite make it. You touch on this a little with your polynomial examples, but it's worth stating explicitly.

    (In some cases non-examples are unnecessary, but in the generic case one should look for them.)

    4. Regarding your polynomial examples, you don't justify that they are, in fact, not polynomials. Now of course you don't, that would be too hard to do here and take up lots of space you want to use for other things. That's fine. But if you're not going to do it, you should call out that you're skipping over it, like you do with other things. After all, all sorts of nonobvious things can be polynomials -- such as (x-1)(x+6)^2, as you pointed out earlier, but included no similar examples here. (Yes that's obvious to anyone who knows anything about polynomials, but my point is that it's not in the correct syntactic form.) Like, x^e - x^e is a polynomial, you know? Because it's 0. So without some more knowledge, you can't immediately conclude that your example x + x^2 - x^pi + x^e is in fact not a polynomial! You should make a note of that, as I said.

    5. I feel like it's likely worth noting somewhere in this chapter that actually in general in math it's the "syntactic" definition of polynomial that turns out to be the right one (you don't want to define polynomials to be functions if you're working over a finite field, say!). Maybe not and that would just be confusing, I dunno.

    6. This is just nitpicking, but I'd suggest rewriting Theorem 2.3 in a clearer, more standard way. "A nonzero polynomial of degree n has at most n distinct roots." What you wrote down is equivalent, of course, but (IMO) harder to read.

    Otherwise, this is pretty nice. I remember being distinctly confused by stuff like "the product over j not equal to i" when I was a kid. I imagine it'll be quite helpful to a number of people that you're laying things out like that explicitly.

    Actually, sorry, on that note, one further comment:

    7. You comment on how sigma and pi notation are special cases of fold, but you might want to make a further note about how (unlike general folds) these are folds where the order doesn't matter, and that the fact that the order doesn't matter is one of the things that allows notation like "product over j not equal to i".

  • by 40acres on 12/1/18, 11:31 PM

    Thanks for the effort. I purchased the e-book and will start working through it immediately. I'll let you know what I think.
  • by codesuki on 12/1/18, 11:47 PM

    Just ordered from Amazon! I used to read his blog a few years ago and I loved the articles and the breadth of topics. Thank you!
  • by hdt91 on 12/2/18, 12:09 AM

    From the ToC, is the any reason there is no chapter covering probability/statistics? It has chapters for single/multivariable calculus and linear algebra, and all CS programs I know have all three, especially when there are some nice connections between them, not to mention how useful they are in other CS/engineering subjects.
  • by holmberd on 12/4/18, 2:09 PM

    Ebook a tad too expensive for me.
  • by alan_wade on 12/2/18, 2:32 AM

    Can you create an EPUB version? I'd like to buy it but I need EPUB for my reader.
  • by wainstead on 12/2/18, 1:15 AM

    Please tell me you wrote it in LaTeX. It would be another reason to buy it.
  • by antoinevg on 12/2/18, 5:48 AM

    I tried to buy it but for some reason Paypal refuses to use my existing balance and instead asks for my card.

    Is this something you can control on your end?

  • by blt on 12/1/18, 11:38 PM

    minor suggestion: make it easier to see the table of contents. A survey book leaves uncertain exactly what is included.
  • by billfruit on 12/2/18, 5:54 AM

    Does it compare to Don Knuth, et al, "Concrete Mathematics: A foundation for Computer Science"?
  • by master_yoda_1 on 12/2/18, 2:07 PM

    I think the author is confused. His book is not for programmers his book is for "programmers lacking computer science education" as computer science is a branch of applied match. If somebody says they have a computer science degree and they don't know math, I would doubt their degree.
  • by harias on 12/2/18, 12:24 PM

    I see a lot of users are learning maths for machine learning. I did the same and here is what I found:

    I started with 3blue1brown's Youtube course[0] on Linear Algebra and loved it. I had already done a college course on LA, but this made me truly understand what I was doing.

    MIT OCW Scholar(independent study) course on Linear Algebra by Prof. Strang[1] is really good and is designed for self-study. If you have the time, you could look up Coding the matrix[2] too. I read probability from Mathematics for Computer Science-MIT[3] and also referred Khan Academy[4] and PennState STAT 414/415 [5] for statistics and probability. StatQuest channel[6] on Youtube has handwavy but easy to understand videos on statistics for ML too. The Deep learning book[7] by Ian Goodfellow et al. has a couple of chapters at the beginning that gives you a fairly good idea of the mathematics required to get into Deep learning. Communities like r/AskStatistics and r/statistics on Reddit were really helpful when I got stuck.

    I also chanced upon Mathematics for Machine Learning[8] book recently and it seems to be good. It has a chapter on optimization that is left out in most books but it skips statistics.

    [0] - https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2x....

    [1] - https://ocw.mit.edu/courses/mathematics/18-06sc-linear-algeb....

    [2] - http://codingthematrix.com/

    [3] - https://courses.csail.mit.edu/6.042/spring18/mcs.pdf

    [4] - https://www.khanacademy.org/math/statistics-probability

    [5] - https://onlinecourses.science.psu.edu/stat414/

    [6] - https://www.youtube.com/user/joshstarmer/videos

    [7] - https://www.deeplearningbook.org

    [8] - https://mml-book.com

    Copied from my comment here: https://news.ycombinator.com/item?id=18582022

  • by nootropicat on 12/1/18, 11:26 PM

    The description got me excited, but looking at the table of contents, the level is ultra basic - appears to roughly correspond to first year of a cs degree.
  • by Nasuno on 12/7/18, 10:33 PM

    A section on quaternions would be nice.
  • by herostratus101 on 12/2/18, 4:57 AM

    I'm a little skeptical of CreateSpace.

    Why did you decide to self-publish?

  • by 00067349 on 12/2/18, 3:21 PM

    why is it not working
  • by ziont on 12/2/18, 12:17 AM

    I am basically trying to understand the formulas in machine learning papers, will this book help achieve improvements in speed?

    I just realize I fear math because the educational system I grew up in was violent (like beating kids for getting a quiz wrong wtf).

    It was only through psilocybin mushrooms did I discover math and calculus again.

  • by mlevental on 12/1/18, 11:51 PM

    Jeremy, been reading your blog for years. Just wanted to say thanks for the wealth of readable intros to interesting mathematics.
  • by liftbigweights on 12/1/18, 11:41 PM

    I guess this is for the nontraditional programmers since computer science is a mathematical field and programming is simply applied mathematics in some sense. I don't see how you could get a CS degree without being competent in mathematics to some degree since CS is a mathematical field.
  • by andrepd on 12/2/18, 1:08 AM

    From the bit I've read from https://pimbook.org/pdf/pim_first_pages.pdf it seems to be very very poor.

    * 19 pages of droning before you start with something concrete. Much talk talk talk about your experiences before you get to the point. I can't put into words how much it frustrates me when I'm expecting to read something interesting and the author takes 3 paragraphs talking about nothing (usually with lots of overexcited exclamation marks).

    [sorry if I am being blunt, but it's how I feel]

    * Imprecise definitions. This defeats the purpose of learning mathematics. Like Leslie Lamport says, rigour in mathematics is not a hurdle or a chore one must endure, it's the whole point of learning the damn thing. You give imprecise definitions, and then obscure it even further with neverending paragraphs of confusing explanations. This to me kills the whole pedagogical value the book might have. Here is a rule of thumb that in my experience applies well to almost everything in mathematics: the simpler your explanation is, the better. Your goal is to explain a concept as succintly and beautifully as possible. This exposes the idea behind it. A long and meandering explanation only serves to obscure the idea behind. Less is more.

    * Attempting to shoe-horn programming "lingo" into mathematics. Sometimes, the best way to explain something, even to programmers themselves, is not to force an awkward analogy with Java programming. EDIT: 5 pages later: "The best way to think about this is like testing software." oh boy...

    * The graph in e.g. page 8 (20 of the pdf) is terribly typeset. The axes text is way too small to read and in a font that doesn't match the rest of the content.