Comments on: How much and what type of math is beneficial to programming?
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming/
Comments on Ask MetaFilter post How much and what type of math is beneficial to programming?Thu, 29 Jan 2015 00:04:41 -0800Thu, 29 Jan 2015 00:39:54 -0800en-ushttp://blogs.law.harvard.edu/tech/rss60Question: How much and what type of math is beneficial to programming?
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming
How much and what type of math is beneficial to programming? What are the prerequisites / pathways to grokking this kind of math? <br /><br /> Firstly, I know that you can be a perfectly productive, efficient and employable programmer with only rudimentary knowledge of math. I have a rudimentary knowledge of math. I finished studying math at the GCSE level in the UK, so I'm missing what ever would be taught at 'A' level math, or presumably VCE math in Australia (unsure of US equivalents).<br>
<br>
But, I was interested in following the MIT opencourseware course for Introductions to Algorithms and int he first few minutes the prof states that the prior course, Math for Computer Science was a prerequisite. So I quit that video, and found video 1 for Math for CS...I could follow most of that, but felt I'd have an easier time if I took one more step back. The trouble is, I don't know what step that should be. I took a look at the Khan Academy tracks for math and the options were not helpful. Do I want to look at algebra, calculus, probability, or something else?<br>
<br>
So please help me map out a sensible pathway for learning the math that will help with my main interest in programming and better understanding algorithms. We'll assume I can do arithmetic and basic algebra, and I can remember Pythagoras' theorem, and how to figure out the area of a circle, but not what sin, cos, tan mean or what they are used for.<br>
<br>
If you mention an area in math worth pursuing, please suggest what area of programming it is beneficial for.post:ask.metafilter.com,2015:site.275149Thu, 29 Jan 2015 00:04:41 -0800man down underComputerscienceprogrammingmathematicsresolvedBy: Xany
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992600
So in first year university, I failed math but got a near-perfect grade in programming. So the short answer (as you know) is, not a lot... however! <br>
<br>
What I've found most valuable as a programmer (and, more distantly, as a student learning programming) have been:<br>
<br>
- algebra (how to use variables is essentially algebra)<br>
- basic matrices and linear algebra (this is a good foundation for arrays)<br>
- basic statistics and probability is very useful for determining results of algorithms <br>
<br>
More niche:<br>
- vectors and vector arithmetic (the follow-on from matrices, from memory) are useful if you want to do 3D programming<br>
- advanced stats/probability (although I would only pick this up if you needed to, if you keep going in programming)<br>
- mod arithmetic is the core of cryptography and generally useful, but not essential for a beginner<br>
<br>
Not useful unless you are given an assignment specifically for it (IMHO, YMMV):<br>
- trigonometry (there are generally functions available if you really need to calculate sin(x) etc)<br>
- calculuscomment:ask.metafilter.com,2015:site.275149-3992600Thu, 29 Jan 2015 00:39:54 -0800XanyBy: neckro23
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992603
Xany has it pretty well covered. I'd add that Boolean algebra is essential, and basic trigonometry is often used in 2D graphics.<br>
<br>
Calculus is the great nutcracker of mathematics, and it's well worth learning, but as far as I can tell it's of surprisingly little use in computer science outside of domain-specific problems. Digital signal processing is the most common application I can think of.comment:ask.metafilter.com,2015:site.275149-3992603Thu, 29 Jan 2015 01:03:40 -0800neckro23By: a lungful of dragon
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992606
What kinds of programming problems do you enjoy solving? Linear algebra and topology are useful for graphics programming. Differential geometry can be useful for map generation. Linear algebra and basic set theory are useful for algorithm design and bioinformatics (statistics) programming. Set and number theory are useful for cryptography.comment:ask.metafilter.com,2015:site.275149-3992606Thu, 29 Jan 2015 01:09:10 -0800a lungful of dragonBy: aubilenon
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992609
I would bump statistics and combunatorics up on that list. It's good for thinking about algorithmic performance but it's also super useful for any kind of analysis of all kinds of stuff that happens. Performance analysis is one example (the data is always noisy). Another is: the thing crashed one time in a hundred. How many times do I need to run it before I'm confident I fixed that?comment:ask.metafilter.com,2015:site.275149-3992609Thu, 29 Jan 2015 01:12:30 -0800aubilenonBy: BigCalm
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992636
<i> If you mention an area in math worth pursuing, please suggest what area of programming it is beneficial for. </i><br>
<br>
Logic - AND / NOT / OR etc is used all the time in all areas of programming. Some extremely rudimentary knowledge of algebra is helpful but not really essential.<br>
<br>
You pretty much don't need Maths at all beyond this in a normal programming situation. There's some exceptions though.<br>
<br>
Graphics - is extremely maths heavy - though an engine / libraries will hide most of the hard work from you. Vectors / Matrices / Quaternions / Mechanics all come into play here and it's mostly degree-level or beyond type stuff.<br>
<br>
Some database stuff can be easier if you understand set theory.comment:ask.metafilter.com,2015:site.275149-3992636Thu, 29 Jan 2015 03:42:23 -0800BigCalmBy: escabeche
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992654
I often teach the introductory math course for computer science majors here at Wisconsin, so I can tell you exactly what the CS department here thinks its students should know. It's pretty much in concordance with the answers here.<br>
<br>
Logic (boolean operators, basic rules of inference, quantifiers)<br>
Asymptotic notation (what the Landau notation "big-O" means, which functions grow more quickly than which other functions)<br>
Basic number theory (probably less critical for most programmers, but explaining how RSA works is super-fun and demonstrates to novice programmers some basic ideas in crypto)<br>
Mathematical induction<br>
Basic graph theory (graphs, trees, counting trees, etc.)<br>
Basic probability (notion of probability distribution and expected value and not much more -- e.g. no central limit theorem)comment:ask.metafilter.com,2015:site.275149-3992654Thu, 29 Jan 2015 04:26:51 -0800escabecheBy: Obscure Reference
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992656
It depends on what kind of programming. When I worked in operating systems, I needed to understand queuing theory which means I needed to understand calculus and differential equations and various kinds of algebra and probability theory. I also needed to understand analysis of algorithms which meant combinatorics and graph theory. Obviously I needed to know how to deal is hexadecimal and octal and how to do XOR and such. <br>
<br>
If you're doing graphics, you might need to know vectors and trigonometry (the latter is useful also in plotting the positions of things on maps or in the real world--a friend who writes iPhone apps uses a lot of trig for that reason).<br>
<br>
If you're doing encryption, you need to know number theory and group theory. Also related is stuff involved in error correction and detection which uses group theory and information theory.<br>
<br>
If you're doing accounts receivables, you just need arithmetic (but keep in mind that there's a lot of mathematics involved in understanding errors involved in rounding--how floating point calculations can lose a lot of digits which turns into a lot of money, or if you're programming for scientists, a lot of data precision).<br>
<br>
If you're programming for Wall Street, they want you to understand probability and statistics which, in turn requires calculus.<br>
<br>
A lot of the time you can get away with using programming libraries that other who understood the mathematics already wrote for you.comment:ask.metafilter.com,2015:site.275149-3992656Thu, 29 Jan 2015 04:35:53 -0800Obscure ReferenceBy: Krop Tor
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992658
The <a href="http://en.wikipedia.org/wiki/Discrete_mathematics#Topics_in_discrete_mathematics">topics section from the wikipedia article on discrete mathematics</a> gives a pretty excellent overview of what math is actually used and how.<br>
<br>
Of those listed I personally would say that logic and set theory are probably the most introductory topics. Computability is also a really basic (basic as in basic computer fundamentals, not basic as in it's easy to understand) and really fascinating topic that builds off of both logic and set theory and will likely really help with an algorithms course. <br>
<br>
I would also agree with the above posters that looking into asymptotic notation/complexity analysis is probably vital to your understanding of an algorithms course as well. I don't even know where that fits in with math, but it's something most CS students learn in their first year or so, and it just becomes assumed knowledge after that.<br>
<br>
After you have all those you will probably have enough of an understanding to know where to look when you start having issues with the algorithms course, which is probably exactly where many students in the MIT course would also be when taking it (if it's anywhere like where I did undergrad). <br>
<br>
From there pick a topic you're interested in and match the math to it. Machine learning? Statistics! Networking? Graph theory! Doing all the math is probably overkill after the basics unless you're really into math.comment:ask.metafilter.com,2015:site.275149-3992658Thu, 29 Jan 2015 04:44:03 -0800Krop TorBy: empath
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992685
Really depends on what you're doing. I very rarely use anything beyond basic arithmetic, but that said, I found more abstract topics like abstract algebra, topology, number theory and category theory useful for understanding how to think about problems. Not necessarily studying them, but reading about them.comment:ask.metafilter.com,2015:site.275149-3992685Thu, 29 Jan 2015 05:46:33 -0800empathBy: hoyland
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992688
escabeche's answer should mirror the Math for Computer Science course pretty closely. Most people are telling you things not relevant to your basic computer science courses. When I took the equivalent course (ours was called Discrete Math, which is a pretty common name), I think the prerequisite was "sufficient mathematical maturity" which means "nothing specific, but the class isn't dead easy". These courses probably tacitly assume the ability to multiply matrices, so I'd maybe use learning about matrices as a way to get back into the math groove. Discrete math tends to be really different to what you saw in school (you probably did some of the basic probability stuff and have forgotten*) and my guess is that you need to plod through the Math for Compute Science course slowly but surely. If you want more prep, the first three sections from the Khan Academy <a href="https://www.khanacademy.org/math/probability/probability-and-combinatorics-topic">probability and combinatorics</a> will get you in the right mindset. (It's really part of that standard undergrad discrete math material, but doing more won't hurt you.)<br>
<br>
(Technically the asymptotic stuff requires limits, but I think people tend to handwave the limits in undergrad CS classes.)<br>
<br>
<small>*In the US, permutations and combinations are always taught with problems like "how many ways can you arrange the letters in MISSISSIPPI" and "how many license plates are there that fit requirements X, Y, Z", the latter especially being irrelevant in Britain, but maybe that triggers some vague memory. Very basic probability is coin flips.</small>comment:ask.metafilter.com,2015:site.275149-3992688Thu, 29 Jan 2015 05:55:19 -0800hoylandBy: escabeche
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3992774
The reason I said big-O and not little-o is that you can define big-O precisely without limits, but little-o is trickier unless you are willing to handwave about limits or something equivalent to limits. Trust me, I learned this the hard way.comment:ask.metafilter.com,2015:site.275149-3992774Thu, 29 Jan 2015 08:02:45 -0800escabecheBy: invitapriore
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3993066
Discrete math is the big one. It's less a branch of math than a pedagogically-convenient grouping of a bunch of different branches that deal with structures that aren't continuous, unlike e.g. calculus which depends on the continuous nature of the real numbers. It seems to me that most discrete math classes open with a discussion of proof technique, which is IMO the most important part -- a lot of the things you cover in discrete math, like graph theory, start from simple premises (a graph is just a bunch of nodes with connections between some of them) but build to complex implications which require a solid and rigorous reasoning ability to work through.<br>
<br>
Some other subdomains of programming that make use of certain branches of math:<br>
<br>
Machine learning -- basic linear algebra, but especially statistics<br>
Audio programming -- depending on how low-level you get, basically everything relating to DSP, which is a lot: trigonometry, some calculus, information theory, numeric methods (basically, the study of approximating mathematical operations that can't be computed precisely because they require infinite precision), ...<br>
Programming language design -- type theory, category theory, automata theorycomment:ask.metafilter.com,2015:site.275149-3993066Thu, 29 Jan 2015 12:39:40 -0800invitaprioreBy: tommasz
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3993081
My CS undergrad math was two quarters of calculus plus one quarter of discrete math (competency in algebra and basic trigonometry was assumed).<br>
<br>
I have used what I learned in discrete math throughout my career. I have yet to use anything I learned in calculus. The only other math-related skill that has come in handy is statistics which I would recommend if available to you. I've done mostly embedded systems programming so perhaps my experience isn't universal (i.e. YMMV).comment:ask.metafilter.com,2015:site.275149-3993081Thu, 29 Jan 2015 12:52:32 -0800tommaszBy: SemiSalt
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3993095
There is something to know about business math. Stuff like how interest is calculated and when a percentage, e.g. a commission, is rounded to the nearest cent.<br>
<br>
I was once told to write a program for mortgage that would find the combination of options that would allow largest loan amount. Among other thongs, it required an understanding of local and endpoint optimums.comment:ask.metafilter.com,2015:site.275149-3993095Thu, 29 Jan 2015 13:05:44 -0800SemiSaltBy: man down under
http://ask.metafilter.com/275149/How-much-and-what-type-of-math-is-beneficial-to-programming#3993104
These are all great answers and exactly what I was looking for!<br>
<br>
Escabeche - It was Big-O notation that got me thinking about all of this in the first place. Simply trying to speed up one function I wrote opened up a whole world of algorithm analysis that was much more interesting than the function itself :)<br>
<br>
Thanks all - I'm going to retreat into a math cave now.comment:ask.metafilter.com,2015:site.275149-3993104Thu, 29 Jan 2015 13:12:56 -0800man down under