Live data from Hacker News

Mathematics for Computer Science [pdf]

courses.csail.mit.edu

71–80 of 161 posts

Re: Mathematics for Computer Science [pdf]

#71

This fall I will be teaching the required "Discrete Math for CS course" to about fifty students at the University of South Carolina. Previously I used Epp's book [1] which in my opinion is an outstanding book but regrettably is $280.44. Many of our students are working minimum wage jobs to make ends meet, and I don't want to make them pay so much if I can at all help it. Lucky I saw this!! I do have one reservation t…

Honest question, why would you spend weeks doing proof by induction? Looking it up, I think I did that when I was 16, but I've never used it while programming. I can't see a single benefit to knowing it for programming. Been programming professionally for 12 years now. What am I missing? Why do you think it's important?

> Looking it up, I think I did that when I was 16, but I've never used it while programming.

Any reasoning about loops or recursion requires an implicit understanding of proof by induction. Making it formally explicit seems like a perfectly fine idea.

Re: Mathematics for Computer Science [pdf]

#72
post #69

This document is over 900 pages. How long are you supposed to take to read and understand all of this? And is this really all necessary? On the surface this looks like an insurmountable task with questionable benefits. Don't get me wrong, but in the past 6 years of casual and professional programming, I've needed only a basic understanding of math, the most difficult thing being collision detection in games, and that…

I have found the mechanics of mathematical proof invaluable when programming, because they show you how to be very clear about what you do know and what you don't know. Basically "Is this thing just a random example, or something that is true in all cases?"

When I work on complex algorithms or concurrent systems I really feel the benefit of proof, because there's no way I could just test if the code is correct.

In the book, explaining what a proof is, how proofs are typically constructed and how to write a good one takes them ten pages, all written in very down-to-earth language. Then there are eight pages of problems you could do if you wanted to test your understanding.

I bet if you read those ten pages you'd feel there was nothing special there, just obvious ways to reason about things.

Re: Mathematics for Computer Science [pdf]

#73

Earlier quoted context omitted.

It's helpful for truly understanding recursion.

If it's so useful for "truly" understanding it, why do I have to show so many CS educated juniors how to use recursion? Have to point out to them to use it instead of doing crazy nested loops or other stupid solutions to a problem simply solved using recursion? Given that I obviously don't "truly" understand it, having never done a CS degree. I'd posit that most CS students don't truly understand recursion, they just…

eh, I posit that you already understand induction and just don't know that you do.

"So many CS educated juniors" being uncomfortable with recursion is not an argument against understanding mathematical induction. Who says they understood induction?

Re: Mathematics for Computer Science [pdf]

#74

This fall I will be teaching the required "Discrete Math for CS course" to about fifty students at the University of South Carolina. Previously I used Epp's book [1] which in my opinion is an outstanding book but regrettably is $280.44. Many of our students are working minimum wage jobs to make ends meet, and I don't want to make them pay so much if I can at all help it. Lucky I saw this!! I do have one reservation t…

[deleted]

Re: Mathematics for Computer Science [pdf]

#75

This fall I will be teaching the required "Discrete Math for CS course" to about fifty students at the University of South Carolina. Previously I used Epp's book [1] which in my opinion is an outstanding book but regrettably is $280.44. Many of our students are working minimum wage jobs to make ends meet, and I don't want to make them pay so much if I can at all help it. Lucky I saw this!! I do have one reservation t…

Buy older or used my friend:

http://marginalrevolution.com/marginalrevolution/2004/09/the...

http://marginalrevolution.com/marginalrevolution/2004/12/the...

https://www.amazon.com/gp/offer-listing/0534359450/ref=dp_ol...

Re: Mathematics for Computer Science [pdf]

#76
post #69

This document is over 900 pages. How long are you supposed to take to read and understand all of this? And is this really all necessary? On the surface this looks like an insurmountable task with questionable benefits. Don't get me wrong, but in the past 6 years of casual and professional programming, I've needed only a basic understanding of math, the most difficult thing being collision detection in games, and that…

In professional programming, most of the time, system design is most crucial and would use less of these mathematics. These 900 pages is not insurmountable. A discrete mathematics course for year 1 computer science students would have covered a good 70% of it. Such a course takes only 3 months and is 1/5 of a student's workload.

The benefits of these is hardly questionable. Its use is apparent when you take a Design and Analysis of algorithms course like https://www.youtube.com/watch?v=JPyuH4qXLZ0. A good example of using knowledge of the pdf is analysing expected runtime of a hashtable. Which turns out to be theta(1) average case. Good analysis of algorithms inspire better design of it in general.

Data structure and software engineering courses would probably be sufficient for many software engineering jobs out there. Databases, networks, OS and security are good to have knowledge. However, if an engineer is building cutting edge stuff, Mathematics will be his/her best friend.

One good property of Mathematics is that it provide guarantees in the form of equality, inequalities or equivalences. Such guarantees can help you ensure that your system holds quantitatively. It is thus your job to reduce your computer science/engineering problem to a mathematics problem.

I find this remark by Terence Tao particularly good: "If you don’t have mathematical background, the classes you take will help you train to analyze existing systems and build things that haven’t been built before. If you want to design something really new, at some point you’ll have to model what you’re doing, which might be different from previous models, and you have to do some mathematics somewhere." This remark is made in this interview: https://docs.google.com/document/d/1rinL25rC8LnMTzZcGjg1axT-...

Re: Mathematics for Computer Science [pdf]

#77

This fall I will be teaching the required "Discrete Math for CS course" to about fifty students at the University of South Carolina. Previously I used Epp's book [1] which in my opinion is an outstanding book but regrettably is $280.44. Many of our students are working minimum wage jobs to make ends meet, and I don't want to make them pay so much if I can at all help it. Lucky I saw this!! I do have one reservation t…

>> "the book appears open source"

Yes, these are the terms of the license:

https://creativecommons.org/licenses/by-sa/3.0/legalcode

Webpage for the course is here: https://learning-modules.mit.edu/class/index.html?uuid=/cour...

That page includes an email contact for the course; (6042-gradesmaster@mit.edu). If you're planning to release an edit, I'd reach out as soon as possible to give them time to get back to you on if they'd be interested in working with you and the best way to do so, since you posting it randomly somewhere on the net would likely do less good in my opinion, but would be a huge help if done with them.

Re: Mathematics for Computer Science [pdf]

#78

This fall I will be teaching the required "Discrete Math for CS course" to about fifty students at the University of South Carolina. Previously I used Epp's book [1] which in my opinion is an outstanding book but regrettably is $280.44. Many of our students are working minimum wage jobs to make ends meet, and I don't want to make them pay so much if I can at all help it. Lucky I saw this!! I do have one reservation t…

Honest question, why would you spend weeks doing proof by induction? Looking it up, I think I did that when I was 16, but I've never used it while programming. I can't see a single benefit to knowing it for programming. Been programming professionally for 12 years now. What am I missing? Why do you think it's important?

In some sorts of code, you can get a lot of mileage from "loop invariants" and "loop variants". Understanding these is more or less the same as understanding proof by induction.

Whether you are missing anything depends on whether you ever write the sort of code that benefits from this. (Even if you do, you still might not be missing anything. You might be comfortable with loop invariants but not have connected them with proof by induction. Or you might be good at reasoning about these things in other ways that don't involve invariants.)

(You can stop reading here if you're already very familiar with loop variants and invariants.)

Here's the sort of thing I mean by loop variants/invariants. Suppose you're writing a binary search. (Don't write a binary search. Use someone else's that's already had the bugs taken out.) This is basically pretty simple but surprisingly easy to get subtly wrong, which means it's the sort of code it may be useful to write and document in such a way that you have an informal proof of its correctness. Like this:

  function find(a, x):
    # find x in sorted array a; return index i such that a[i]==x
    # or -1 if no such index exists. Takes time at most
    # proportional to log(#elements).
    lo,hi = a.index_bounds()
    while lo= hi which means there's nowhere for x to live
    return -1
The above is pseudocode in no particular language. Is it correct? Those variants and invariants (1) divide that question in two and (2) provide a strategy for answering the second half of the question. First sub-question: if the (in)variants always hold, does that imply that the code is correct? Second sub-question: do they always hold? (Strategy for second sub-question: proof by induction on array size and/or number of iterations.)

The first invariant implies that since mid is always between lo (inclusive) and hi (exclusive) it's safe to access a[mid]. The second, given that it holds at both start and end of the loop body, implies that if we exit the loop then indeed x isn't in the array. The only ways to leave the function are via the return in the middle, which only happens when we have explicitly found x, and via the return at the end, which only happens when x is known to be absent; therefore, if we return anything, we return the right thing. And the variant says that the quantity D, which starts by equalling the number of elements in the array, is reduced by a factor of at least 2 at each step; as it's always a (strictly) positive integer, this implies that the number of steps is at most log_2(n), so the function does return.

(Note that that last bit is more or less a proof by induction on array size that the function always returns.)

So if the invariants hold then the function does the right thing in the right amount of time.

Proving that the invariants hold is the induction-like bit. The first invariant holds at the start (since lo,hi start out being exactly min index and max index + 1). Each time around the loop we replace either lo or hi with something in between the two, so we still have min The second invariant holds at the start (since lo,hi are bounds on the entire array). Because the array is sorted, our adjustments to lo/hi make this invariant true again for the next time around the loop. So the second invariant holds at the end of the loop -- and of course therefore at the start of the next iteration.

(Note that those were both proofs by induction, though I wasn't super-explicit about the fact.)

The variant works because if we write D = hi-lo and E = floor(D/2) then the new value of D is, depending on which branch of that if we take, either E or D-E-1; note that D-E-1It's probably pretty clear what sort of code this is useful for: highly "algorithmic" code that's basically doing something fairly simple but that's tricky to think about and easy to get wrong. If you're writing a language's standard library, or implementing some sort of iterative mathematical algorithm, then you're quite likely to find it useful. The less like that your code is, the less often this technique will be useful to you. (Fairly extreme example: if you are writing a CRUD webapp then it is unlikely that anything you do will benefit from this.)

Re: Mathematics for Computer Science [pdf]

#79

This is so stupid, the "primer on the basics" should be "Algorithmization for Computer Science", not a 900+ page math textbook (that doesn't even explore graph theory, calculus and differential calculus).

Read the TOC again, there's plenty of graph theory. Calculus isn't important for CS.

Re: Mathematics for Computer Science [pdf]

#80
post #10

Is this a good start for Math required for Machine Learning ?

No, this is for a general introduction to the mathematics of computer science. This looks like a basic (and good!) text any MIT freshman should be able to master. Perhaps it's for what 6.001 has morphed into? If you understand this stuff, you really need linear algebra for today's "deep learning", which perhaps is 18.03 (I can no longer remember).

[deleted]
Post reply on HN