[HN Gopher] A Programmer's Introduction to Mathematics
___________________________________________________________________
A Programmer's Introduction to Mathematics
Author : __rito__
Score : 288 points
Date : 2023-05-03 09:45 UTC (13 hours ago)
(HTM) web link (pimbook.org)
(TXT) w3m dump (pimbook.org)
| quasarj wrote:
| Loved it up until the introduction of proofs. Still can't wrap my
| mind around it. I'm beginning to think it's because "proofs"
| don't prove anything, they are just an argument that someone
| might find convincing.
| bo1024 wrote:
| Proofs as usual written are informal summaries, but they are
| supposed (in today's age) to be linked to a very rigorous
| series of steps more precise than a Haskell program. Actually,
| it's very similar to the execution of a Turing Machine (there
| are formal connections):
|
| * There is a finite set of logical rules. For example, one rule
| is that if A => B and B => C are true, then A => C is true.
|
| * We start with a finite set of given facts.
|
| * At each step, we state a new fact and note it is true by
| combining previous facts with a rule.
|
| * At the end, we have the claim we started with.
|
| Example: prove 14 is an even number.
|
| 1. If a number equals two times an integer, it is even (given
| fact).
|
| 2. 7 is an integer (given fact).
|
| 3. 14 = 2 times 7 (laws of multiplication).
|
| 4. 14 = 2 times an integer (combining (2) and (3)).
|
| 5. 14 is even (combining (1) and (4)).
|
| At a more complex level, e.g. proofs by induction are often no
| more than programs with for loops.
| tutfbhuf wrote:
| A computer program can also be considered a form of
| constructive proof. One may be confident that the program
| functions as intended until a bug is discovered. This is why
| theorem provers have such a strong type system, which reduces
| the likelihood of bugs compared to mainstream programming
| languages. However, it is important to note that bugs may still
| be present, just as they can be found in formal proofs on
| paper.
| quasarj wrote:
| Do they have a strong type system? Maybe I just haven't
| gotten to that. My issue is that, there doesn't seem to be
| any rules for "evaluating" a proof to see if it is valid.
| Everything seems subjective? Maybe I'm just missing
| something. But coming from programming, I'm obviously used to
| a situation where I can put my code through a mechanical
| evaluator which will tell me if it works. Or at least, will
| tell me if the syntax is right!
| lying4fun wrote:
| When you proove something you are esentially prooving that
| a statement logically follows from some other statement(s)
| for which we know that are true
|
| You can evaluate the validity of a proof by checking the
| truthfulness of every statement which was used to argue
| that the proof holds
|
| Miniature example of a proof with relaxed rigor:
|
| Proove that 3+0=3
|
| Proof: The above statement is a direct consequence of the
| additive identity axiom which states that x+0=x, if x is a
| real number. So the only thing we need to check is if 3 is
| a real number, and we know that it is. The statement holds,
| end of proof
|
| So to check the validity of this proof you could check if
| that axiom really exists and check if 3 is a real number,
| if some of those is false than the proof is invalid
|
| Edit: Or imagine that you have a DB full of axioms,
| theorems, prooven statements which you can use to proove a
| given statement. Then you could proove something by just
| referencing those. Eg. in the example above lets say that
| the neutral identity axiom has id 3, and the fact that 3 is
| a real number has an id 103. Then I could just say since 3
| and 103 3+0=3
| crabbone wrote:
| Why did the author choose such an awful example to start with
| (polynomials with real coefficients)? This is just upsetting: one
| would hope to understand things (i.e. to derive them from first
| principles), but instead are given another hand-waving "trust me
| bro, it works" kind of start...
|
| Why even go into anything that requires "real" numbers when
| talking to programmers, if no real numbers can possibly exist in
| computers? You don't need "real" numbers for logic, nor for
| algebra, neither for combinatorics and many, many more useful
| areas of mathematics (from programming perspective). And yet the
| reader is required to take on faith some "math wizardry"...
|
| Even if the author wanted so much to have polynomials, why not
| take polynomials with rational coefficients? -- A much easier to
| digest concept that requires no hand-waving and works just as
| good for the purposes of illustration?
| detrites wrote:
| For me, and I guess for programmers in general, as presumably
| anticipated by the author, the concept of floating point
| numbers as a pure construct without having to cram them into n
| bits was easy to grasp, even relaxing.
|
| Perhaps that was the intention there.
|
| As for choosing polynomials in general as a starting point, a
| potential answer is maybe found in the text:
|
| > Polynomials occur with stunning ubiquity across mathematics.
|
| That is, beyond the concept of basic arithmetic that's surely
| already known, it's possibly a logical place to begin.
| weinzierl wrote:
| I like that - in addition to covering the usual topics - it has a
| chapter about groups. Maybe this is just my bubble but in my
| experience math courses for non-mathematicians are often lacking
| in this area. In the same vein a basic introduction to topology
| could be a nice addition to a future version of the book.
| revskill wrote:
| Again, one more "failure" of attempting teaching Maths to
| programmers.
|
| My expectation is always, teaching Maths without using any of
| Maths language (forget theorem, signature,...). Is this possible
| ? Yes.
|
| Programmers use code, algorithm, data structure to run the code,
| and to understanding the theory, instead of understanding Maths
| language, which is most of the time, "hurt the brain"
| auggierose wrote:
| [flagged]
| sourceless wrote:
| Teaching maths without "Maths Language" is like teaching
| programming without a Programming Language.
| revskill wrote:
| You don't need to understand "Theorem" to know how to use the
| theory.
|
| You can replace any of Math definition with code.
|
| Is this the point of "for programmers" ?
| JadeNB wrote:
| > You can replace any of Math definition with code.
|
| You often (but not always!) can replace a math definition
| with code--but either your code is sufficiently precise
| that it's just another way of phrasing the definition, or
| you're in the analogous situation to using a language
| defined by its implementation instead of a specification.
| And there's plenty of useful space for such languages--but
| they aren't formally specified languages. Math that isn't
| formally specified isn't math, in any sense that a
| mathematician would recognize--which is not to say that it
| can't be useful.
| citizen_friend wrote:
| I do the opposite, I figure out the math to describe a problem,
| then write the program to do it.
| RugnirViking wrote:
| learning the language of a field is vital if you ever want to
| use anything somebody else figured out. You can't read a paper
| to understand how something works if you dont learn the
| language they use in the paper.
|
| The reason they don't write the paper in "normal english" is
| because that normal english would make the paper thousands of
| pages long with lawyer-speak listing everything they dont mean.
| It turns out there isn't a shortcut to learning it, and after a
| couple lonely evenings slowly translating you will eventually
| be able to skip over that part of notation when you see it.
| repeat for all the maths youre interested in and you will be
| good
| d_tr wrote:
| Rigor and mathematical terminology make it simpler and easier,
| because you can say more things with fewer words and more
| precision. Mathematicians are not masochists. Compared with
| truly understanding the theorems and the concepts, the effort
| to understand the terminology is basically zero.
| madsbuch wrote:
| I would say that the pros of mathematical notation is the
| _opposite_ of rigor. You get to not write everything out,
| which is both good for the lazy reader and lazy writer.
|
| It is just not very good for the newcomer that needs to learn
| the implicit assumptions that are not written out.
| klibertp wrote:
| > because you can say more things with fewer words
|
| You say it as if it was a good thing. It's not. APL, J, and K
| would reign supreme over all programming if brevity and
| conciseness were all that good for people actually
| understanding what the heck is happening.
|
| Math notation is a peculiar, loosely defined, context-
| dependent, ambiguous syntax that requires a lot of
| memorization, a special keyboard when writing, and a lot of
| focus when reading. It only benefits people forced to write
| equations on blackboards all day long. I mean, I feel for
| them, it's a tough job, but I'm _not_ going to be doing that.
|
| > the effort to understand the terminology is basically zero
|
| You say it as if it was a fact. I don't believe it's anything
| else than a gut feeling you have. It's trivial to find people
| for whom the effort needed to understand the terminology or
| syntax was too big of a barrier to entry. If you could show a
| proper, replicated study from scientists working on cognition
| and memory that proves this statement (zero-cost of alien
| terminology), it would be great. Otherwise, I see this as a
| gut feeling coupled with survivorship bias.
| BeetleB wrote:
| > You say it as if it was a good thing. It's not. APL, J,
| and K would reign supreme over all programming if brevity
| and conciseness were all that good for people actually
| understanding what the heck is happening.
|
| On the flip side, try reading all your programs in
| assembly.
|
| Verbosity is nice up to a point. When I look at the math I
| did for physics, solving a problem could take 3 pages. If
| we go with the GGP's approach, it would take perhaps 15-20
| pages. Almost everyone would grok it quicker with those 3
| pages than trying to read a more verbose 15.
|
| It's actually why some prefer functional programming. Which
| is easier to understand:
|
| "Take these student papers, and split them into two groups
| based on whether the student's name begins in a vowel or
| not."
|
| OR
|
| "Create two groups. Call them vowels and consonants. Take
| the first paper. If it begins with a vowel, put it in the
| vowel group. Otherwise put it in the consonant group. Once
| done with that paper, repeat the steps with the next paper.
| Keep repeating till there are no papers left."
|
| And I won't even bother describing how one would do it in C
| (have a counter variable, at the end of each iteration
| explicitly check for termination, etc).
|
| The difference between math formalism and verbosity is
| analogous to the difference between the two descriptions
| above. At some point, more verbosity lets you see the fine
| details at the expense of the big picture.
|
| > It's trivial to find people for whom the effort needed to
| understand the terminology or syntax was too big of a
| barrier to entry.
|
| It's almost impossible to find someone who can do, say
| Griffiths level electromagnetics or quantum mechanics
| _without_ that formalism. Your refrain pops up all the time
| on HN, but I have yet to see someone do even undergrad
| level physics in any of the alternatives suggested.
| okaleniuk wrote:
| I thought so too. When I started Geometry for Programmers, I
| was going to write all the formulas as SymPy snippets. I
| thought that was a brilliant idea because, yes, normally
| programmers are much more comfortable with code rather than
| with math notation, and math is not about notation anyway. Case
| in point, you can turn any SymPy expression into LaTeX with the
| `latex()` function. It doesn't make the expression any more
| mathematical, so the other way should apply just as well,
| right?
|
| But the very first review shown that I was wrong. Very few
| people saw this as a good idea. Most wanted both formulas and
| code. Apparently, there is a certain "comfortable" level of
| math language in a math book readers do not wish to give up.
| franknstein wrote:
| "...and math is not about notation anyway". It most certainly
| is!
| photochemsyn wrote:
| Interesting work, but I think it neglects one of the profound
| distinctions in mathematics that people coming from a
| programming/compsci background often stumble over: that between
| the discrete and the continuous. This looks like a good
| discussion:
|
| > "The distinction between the discrete and the continuous lies
| at the heart of mathematics. Discrete mathematics (arithmetic,
| algebra, combinatorics, graph theory, cryptography, logic) has a
| set of concepts, techniques, and application areas largely
| distinct from continuous mathematics (traditional geometry,
| calculus, most of functional analysis, differential equations,
| topology). The interaction between the two - for example in
| computer models of continuous systems such as fluid flow - is a
| central issue in the applicable mathematics of the last hundred
| years."
|
| http://philsci-archive.pitt.edu/16561/1/Discrete%20and%20Con...
|
| With respect to programming and mathematics, this line is worth
| thinking about: _The problem is that the continuous is easier to
| imagine and prove results about, but the discrete is unavoidable
| when it comes to calculation._
| logicchains wrote:
| The continuous requires the law of the excluded middle, which
| makes it harder to imagine as it's not easy to "construct" an
| image of x in our mind purely from a proof of "not not x".
| That's why non-continuous (constructive) maths is also known as
| intuitionistic maths. For anyone who's not familiar with why
| constructive mathematics is non-continuous, it's because
| without the law of the excluded middle, only the computable
| real numbers (and analogues) exist, not the whole real number
| line that's present in classical mathematics.
|
| The Banach-Tarski paradox is an example of an unintuitive
| result of the LEM, a paradox that doesn't exist in constructive
| mathematics.
| btilly wrote:
| I'm sorry, but classical mathematics is perfectly able to
| handle continuous functions. And in fact it does so more
| easily. Which is why most of the important theorems were
| proven classically first.
|
| Sure, Errett Bishop came along with
| https://www.amazon.com/Foundations-Constructive-Analysis-
| Err... and fixed that. But it is harder. And sure, as soon as
| you start looking at error bounds in numerical analysis, the
| classical shortcuts start to take work. But it is simply
| wrong to assert that the continuous REQUIRES the law of the
| excluded middle.
|
| In fact every mathematician has been through the classical
| treatments of continuity in courses on real analysis and
| topology. Very few can say much that is sensible about
| constructivism.
| ouid wrote:
| The current state of the metatheory of Banach tarski is that
| it follows from the ZF + Ultrafilter, but not ZF + dependent
| choice, and has very little to do with the excluded middle.
| Chinjut wrote:
| It's common to say that constructive mathematics is
| continuous, as it cannot prove the existence of a
| discontinuous function. One can certainly reason
| constructively about the various things traditionally
| considered continuous mathematics. I find your opposite
| perspective on it a bit odd.
| btilly wrote:
| I wouldn't say that it cannot prove the existence of a
| discontinuous function. Rather it can prove that a point of
| discontinuity makes it not a function.
| adamnemecek wrote:
| You should be looking into coalgebras. God they are so obscure
| but so insanely useful.
|
| https://www.youtube.com/watch?v=XqywV-wkKSE
|
| 'discrete mathematics : algebra :: continuous mathematics :
| coalgebra'.
|
| It's like the missing half of math and programming. Power
| series? Coalgebra. Combinatorics? Coalgebra. Continuousness?
| Coalgebra. Bases? Coalgebra. Control flow? Coalgebra [1].
|
| I have a discord https://discord.cofunctional.ai.
|
| [1] https://www.cl.cam.ac.uk/~vb358/articles/mpc15.pdf
| Tainnor wrote:
| > The problem is that the continuous is easier to imagine and
| prove results about [...]
|
| Why would that be true? A cyclic group of order n, or even all
| of Z, seems to me easier to think about than the real numbers
| which employ philosophically tricky notions such as uncountable
| infinity, limits, convergence, etc. There are a lot of weird
| and counterintuitive results even in elementary analysis
| because of the way the real numbers work.
|
| Of course, there's also discrete objects that are hard to
| reason about.
| penteract wrote:
| I think this is written from the perspective of a continuous
| mathematician or physicist, and the examples of discrete
| maths they have have in mind are numerical simulations, which
| are certainly harder to reason about than their continuous
| counterparts.
|
| I also suspect that this is a fairly orthodox attitude among
| mathematicians - in "The two cultures of mathematics"
| (https://www.dpmms.cam.ac.uk/~wtg10/2cultures.pdf) Tim Gowers
| says with more authority than I could:
|
| > the subjects that appeal to theory-builders are, at the
| moment, much more fashionable than the ones that appeal to
| problem-solvers.
|
| This isn't precisely the discrete/continuous split, but it's
| mostly aligned and the article puts combinatorics is firmly
| in the latter category.
| btilly wrote:
| It is true because the discrete world has the potential for
| more fine structure.
|
| As an example showing that it is true, read
| https://math.stackexchange.com/a/362840/6708 explaining how
| it is possible that the real numbers are complete (all first
| order statements about them are either provably true or
| false) while the integers are famously incomplete (no set of
| axioms can prove everything about them).
|
| ALL of the philosophically tricky notions that you list are
| only tricky when you mix in discrete notions like "integers"
| in your construction. And given that discrete mathematics
| gives us things like the Halting problem and incompleteness
| WITHOUT continuity being involved, shows that it is discrete
| mathematics that is harder.
| zelos wrote:
| I found this a great introduction to 'proper' mathematics. It
| gave me enough context to be able to read more mathematics
| without feeling so lost. It also showed me just how bad the
| mathematics part of my (non-computing) engineering education was.
| vasili111 wrote:
| What are prerequisites of math for this book?
| j2kun wrote:
| Oh hi!
|
| I'm working on a second book: Practical Math for Programmers.
| Some details at https://pmfpbook.org/
|
| Every weekend I livetweet my notes and research on the new book
| over at j2kun@mathstodon.xyz, e.g.,
| https://mathstodon.xyz/@j2kun/110283189611214753
|
| Happy to entertain any ideas folks have for topics! Got a long
| backlog to go through, but there's always room for more.
| gdcbe wrote:
| Awesome, I do not have or want mastodon or any social media
| like it, but did sign up for your newsletter. Thank you for all
| your hard work.
|
| Once the next book comes out, I'll buy a couple of copies
| immediately! Looking forward to it!
| jordigh wrote:
| Mathstodon is nice, we have LaTeX.
|
| https://mathstodon.xyz/@JordiGH/110306262198084936
| gdcbe wrote:
| I don't have anything against ' Mathstodon. Just do not
| have any need for social media.
| hintymad wrote:
| Nice. Years ago practical maths to my programming needs was
| Concrete Mathematics for algorithm analysis, combinatorics for
| data structures, queuing theory for performance analysis,
| mathematical stats for data analysis, and optimization theories
| for discrete optimizations. Calculus and linear algebra came in
| here and there as tools for those maths. It looks nowadays
| there's less need for diving into such maths as well-packaged
| systems and libraries solve most of my problems. I'm very
| curious what topics your book will cover for the new generation
| of programmers.
| codepoet80 wrote:
| Thank you for making this. I'm a _good_ programmer, but was
| awful at math in high school and college. I 've often thought
| that now that I'm older (40s) and more patient (most days), I
| would like to try again, but have never found the right
| resource. I don't know if this is it, but I appreciate your
| effort and will order the book ASAP!
| NSMutableSet wrote:
| Is an early access version available for purchase? I would love
| to see the current state of the book.
|
| I will be purchasing your first book sometime this week. I feel
| like I can finally make real progress in learning mathematics
| with ChatGPT as an aide.
| j2kun wrote:
| No early access, but I published a draft of a sample chapter
| here, which is one of the simpler applications, but
| demonstrative of the type of content in the rest of the book:
| https://jeremykun.com/2022/05/14/practical-math-preview-
| coll...
| irajdeep wrote:
| I used to do some "competitive programming" back in university -
| which I think helped me grasp quite a few Mathematics concepts.
| madsbuch wrote:
| Which mathematical concepts would you say that you got to
| grasp?
|
| Having done competitive programming also, I would not say that
| it made any difference for my mathematical perception.
| irajdeep wrote:
| To name a few concepts: "Permutation & Combination", "Proofs
| with induction", "Probability". I did learn some of them from
| university courses, but writing code for them(in terms of
| coding problems) helped cement few of the them for me.
| madsbuch wrote:
| How did you apply induction proofs in competitive
| programming?
|
| Even using recursion is rarely a good idea as you loose
| control with your memory layout.
|
| And using a language that supports the concept of proof by
| induction would surely leave you on the absolutely last
| place for competitive programming as most of the algorithms
| used use guarantees that are extremely difficult to reason
| about _even_ with some of the most recent advances in
| formal methods.
|
| I do see how combinatorics work with competitive
| programming, though. and to an extend also probability
| theory, though I never used any probabilistic algorithms
| myself.
| bombolo wrote:
| > Even using recursion is rarely a good idea as you loose
| control with your memory layout.
|
| Functional programming? NOT TODAY!
| irajdeep wrote:
| > Even using recursion is rarely a good idea as you loose
| control with your memory layout.
|
| Used recursion at tons of Codeforces / ICPC problems with
| some caching(commonly known as "dynamic programming")
| madsbuch wrote:
| I think most problem sets would be hard to solve without
| use of dynamic programming, irrespective of recursion or
| not. But yes, recursion with memorisation/accumulation
| would be a good place to start.
| chazeon wrote:
| Looking through the toc I hope I had known this book earlier. Now
| I am looking for books for the math of more advanced topics, such
| as stochastic calculus, etc.
| gdcbe wrote:
| I bought it back in the days when it first came out, loved it a
| lot. Helped me a lot as a "self-made" programmer. Shortly
| afterwards I actually started a formal pure math education in my
| 30s at uni, but with a second child on the way that journey
| stopped after only completing the first year. In the meanwhile
| there's also a third kid. Still, really fell in love with
| mathematics during my career as a programmer and when the kids
| are bigger it will be a hobby that gets more attention again.
|
| Suffice to say. Love the book. Will it make you a fully fledged
| mathematician? Of course not. Can it teach more or better, sure,
| what not? But it's a great introduction anyway and it may inspire
| many that otherwise might not be inspired. Mathematics is really
| fun if you're not afraid to feel uncomfortable all the time.
| Luckily most good programmers probably have that same feeling all
| the time anyway. I can only hope for more books like this, I have
| some space reserved for them on one of my dusty shelves! Big
| thanks for the author to write this book!
| martingalex2 wrote:
| We need something similar for quantum physics.
| madsbuch wrote:
| This seems to be interesting stuff!
|
| It seems to be heavily focused on Algebra and arithmetic. My own
| recommendation would be to pick up Coq or Idris and use that to
| bridge programming, math and logic. In my experience this is the
| best way to leverage the knowledge. Understanding monads and
| category theory will immediately let you make better API designs,
| architecting larger applications, etc.
| gjadi wrote:
| Any books or links you recommend?
|
| Also, won't learning two things at once be harder than learning
| each independently?
| sva_ wrote:
| https://www.ma.imperial.ac.uk/~buzzard/xena/natural_number_g.
| ..
| nebulous1 wrote:
| Here's a link that was on HN before:
| https://www.neilwithdata.com/mathematics-self-learner
|
| There's no quick fix in there though.
| madsbuch wrote:
| Benjamin Pierce was my go to guy:
| https://softwarefoundations.cis.upenn.edu/index.html
|
| And when that is digested:
| https://www.cis.upenn.edu/~bcpierce/tapl/main.html
|
| And I think the learning should be fun. It is much more like
| taking an adventure into these areas. Especially when it is
| not a part of a course. So learn everything at ones and write
| about it (this is an area that is serious in need of some
| good written blog articles) - Maybe that will also create
| some serendipitous moments :)
| jfoutz wrote:
| I'd throw in Agda with that list. I've enjoyed
| https://github.com/jespercockx/agda-lecture-
| notes/blob/maste...
|
| > Also, won't learning two things at once be harder than
| learning each independently?
|
| kind of, yes. But it's kind of funny. Like, it can take a
| while to get your head wrapped around functional or object
| oriented programming. But once you get a sense of it, you can
| kind of puzzle out any of that style of code. Math is written
| in proofs. after you prove a + (b + c) = (a + b) + c a few
| times, you kinda get a sense of what to look for.
|
| I'm not saying it's easy. I am saying it's not that different
| than becoming fluent in another style of programming.
| functional hello world is still just hello world. deeper,
| more complicated programs are hard no matter the
| language/style. Getting a handle on writing proofs has been
| personally rewarding. (I've been pretty casually studying
| over the last few weeks/months). I don't think it'll advance
| my career or anything, but it's neat.
___________________________________________________________________
(page generated 2023-05-03 23:01 UTC)