What are some good rigid body dynamics references? - math

I'm not a math guy in the least but I'm interested in learning about rigid body physics (for the purpose of implementing a basic 3d physics engine). In school I only took Maths through Algebra II, but I've done 3d dev for years so I have a fairly decent understanding of vectors, quaternions, matrices, etc. My real problem is reading complex formulas and such, so I'm looking for some decent rigid body dynamics references that will make some sense.
Anyone have any good references?

Physics for Game Programmers I think is better than Physics for Game Developers.
If you want something thick in your bookshelf (like I do), Eberly's 3D Game Engine Design and Erleben's Physics-Based Animation can accompany the above.

Chris Hecker has a nice set of articles on his website which were originally published in Game Developer Magazine. They start with 2D physics and progress to 3D.
Physically Based Modeling by David Baraff is also good, but is a bit heavier on the math.

I guess what you are looking for is Classical Mechanics, which describes motion in one, two, and three dimensions in a generalized manner.
I found a good introductory course on Classical Mechanics from the University of Texas.
I do not guarantee that you will be able to understand all the concepts there, but it will at least give you a basis for your plan. I advise you to consult a Physics professor to help you understand the math.
Good luck!

If you are already familiar (and comfortable) with
linear algebra
basic calculus
Newton's laws of motion
then 6DoF Rigid Body Dynamics is what you are looking for. It's a brief article written [disclaimer: by me] when I once had to develop a helicopter flight simulator.
Using a rotation matrix allows for extremely simple modelling equations, but there exists a simple mapping to and from a quaternion if you prefer that representation for other reasons.

Trying not to get you to rip off your hair with frustration (well, Baraff's/Witkin great math articles with the multi-dimensional matrices would do that sometimes), you can look at the easier online articles such as the ones published in Gamasutra.
Here are two of them:
http://www.gamasutra.com/resource_guide/20030121/kennedy_pfv.htm
http://www.gamasutra.com/features/19990702/data_structures_01.htm
http://www.gamasutra.com/resource_guide/20030121/jacobson_pfv.htm
You'd notice that they point at the mentioned resources as part of their references. I would add that unless you need to solve equations system for multiple particles, articulated characters, or non-rigid complex object, this might be enough to start with.
If however, you do look for more advanced physics and mathematics which involves matrices and equations systems look up Witkin and Baraff's home pages (I think they are both in Pixar if I'm not mistaken), or start with Hecker (that tried more than several practical methods and documented his results).

Related

Math me - 2d video games

I'm a hobbyist game programmer. I only do 2d games, no 3d stuff. I don't have a math background and lots of things are tripping me up like bullet projections and angles.
I took two college level Algebra courses at the local community college, but really disappointed. I got As in both, but really don't feel like I'm using any of it in my everyday 2d game programming and still stuck on angles/bullet paths, etc
I dropped out this semester to self study. The advisory at the community college said I want to be in Statistics for this and was really pushing me hard to enroll in that class. He said Statistics then Calculus I & II would get me what I needed.
I've been reading up a lot and not so sure on this. I think I should start with a a Geometry book and then move into Trigonometry? Is that the right approach?
Anyone suggest any good self-study starter books?
I got a lot out of "3D Math Primer for Graphics and Game Development". I know it says 3D but there is a lot of stuff in there for 2D. And the math is fairly simple linear algebra.
It sounds like statistics is useless for what you want to do. Calculus might be marginally useful, but not until you are really solid with it. You probably need to learn trigonometry more than anything else. I could offer more explicit advice if you give an example of a problem you're trying to solve.
There are a few points here:
1) The statistics suggestion is a complete misdirection, and this advice should be completely ignored, along with the person who gave it to you. Statistics is an interesting topic, but not at all useful in game programming (except maybe for a few esoteric approaches to esoteric topics, maybe, like, drawing clouds).
2) (Not that you seem to but...) it's not uncommon for programmers to make the mistake of assuming that they can just learn everything on the job, but most science topics (including math) can not be effectively learned this way. With these, one needs a much more structured approach, building an elaborate structure of ideas, with each new idea built on top of the previous. You could certainly program games with a few equations that you learned to use from a game programming book, but it's unlikely you'd ever have the ability to solve problems that you hadn't already seen solved somewhere else.
3) The best way to get comfortable with math is to solve lots of problems, and not on the computer, but with pencil and paper. For example, you can easily write a program to test that sin2+cos2=1, but to prove it, you need to understand it.
4) Of the topics you'll need, trig is the most time effective place to start. Geometry would be a bit useful, but probably not so much. Another useful topic is linear algebra. Calculus is also useful for calculating trajectories that have acceleration (and gravity), but it's a much bigger topic and involves so many new ideas that it's probably a bit difficult to pick up on your own. Maybe for this topic it's best to try to glean a few useful approaches and equations.
Final suggestion: I recommend starting with trig, and use a book that gives concise explanations followed by lots of problems that are solved in the back. For example, Schaum's Outline of Trig for $13, would probably be a good choice. You don't need to solve a every problem in the book, but work them until you're comfortable, and then move on.

How can I learn higher-level programming-related math without much formal training? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I haven't taken any math classes above basic college calculus. However, in the course of my programming work, I've picked up a lot of math and comp sci from blogs and reading, and I genuinely believe I have a decent mathematical mind. I enjoy and have success doing Project Euler, for example.
I want to dive in and really start learning some cool math, particularly discrete mathematics, set theory, graph theory, number theory, combinatorics, category theory, lambda calculus, etc.
My impression so far is that I'm well equipped to take these on at a conceptual level, but I'm having a really hard time with the mathematical language and symbols. I just don't "speak the language" and though I'm trying to learn it, I'm the going is extremely slow. It can take me hours to work through even one formula or terminology heavy paragraph. And yeah, I can look up terms and definitions, but it's a terribly onerous process that very much obscures the theoretical simplicity of what I'm trying to learn.
I'm really afraid I'm going to have to back up to where I left off, get a mid-level math textbook, and invest some serious time in exercises to train myself in that way of thought. This sounds amazingly boring, though, so I wondered if anyone else has any ideas or experience with this.
If you don't want to attend a class, you still need to get what the class would have given you: time in the material and lots of practice.
So, grab that text book and start doing the practice problems. There really isn't any other way (unless you've figured out how osmosis can actually happen...).
There is no knowledge that can only be gained in a classroom.
Check out the MIT Courseware for Mathematics
Also their YouTube site
Project Euler is also a great way to think about math as it relates to programming
Take a class at your local community college. If you're like me you'd need the structure. There's something to be said for the pressure of being graded. I mean there's so much to learn that going solo is really impractical if you want to have more than just a passing nod-your-head-mm-hmm sort of understanding.
Sounds like you're in the same position I am. What I'm finding out about math education is that most of it is taught incorrectly. Whether a cause or result of this, I also find most math texts are written incorrectly. Exceptions are rare, but notable. For instance, anything written by Donald Knuth is a step in the right direction.
Here are a couple of articles that state the problem quite clearly:
A Gentle Introduction To Learning
Calculus
Developing Your Intuition For
Math
And here's an article on a simple study technique that aims at retaining knowledge:
Teaching linear algebra
Consider auditing classes in discrete mathematics and proofs at a local university. The discrete math class will teach you some really useful stuff (graph theory, combinatorics, etc.), and the proofs class will teach you more about the mathematical style of thinking and writing.
I'd agree with #John Kugelman, classes are the way to go to get it done properly but I'd add that if you don't want to take classes, the internet has many resources to help you, including recorded lectures which I find can be more approachable than books and papers.
I'd recommend checking out MIT Open Courseware. There's a Maths for Computer Science module there, and I'm enjoying working through Gilbert Strang's Linear Algebra course of video lectures.
Youtube and videolectures.com are also good resources for video lectures.
Finally, there's a free Maths for CS book at bookboon.
To this list I would now add The Haskel Road to Logic, Maths, and Programming, and Conceptual Mathematics: A First Introduction to Categories.
--- Nov 16 '09 answer for posterity--
Two books. Diestel's Graph Theory, and Knuth's Concrete Mathematics. Once you get the hang of those try CAGES.
Find a good mentor who is an expert in the field who is willing to spend time with you on a regular basis.
There is a sort of trick to learning dense material, like math and mathematical CS. Learning unfamiliar abstract stuff is hard, and the most effective way to do it is to familiarize yourself with it in stages. First, you need to skim it: don't worry if you don't understand everything in the first pass. Then take a break; after you have rested, go through it again in more depth. Lather, rinse, repeat; meditate, and eventually you may become enlightened.
I'm not sure exactly where I'd start, to become familiar with the language of mathematics; I just ended up reading through lots of papers until I got better at it. You might look for introductory textbooks on formal mathematical logic, since a lot of math (especially in language theory) is based off of that; if you learn to hack the formal stuff a bit, the everyday notation might look a bit easier.
You should probably look through books on topics you're personally interested in; the inherent interest should help get you over the hump. Also, make sure you find texts that are actually introductory; I have become wary of slim, undecorated hardbacks labeled Elementary Foobar Theory, which tend to be elementary only to postdocs with a PhD in Foobar.
A word of warning: do not start out with category theory -- it is the most boring math I have ever encountered! Due to its relevance to language design and type theory, I would like to know more about it, but so far I have not been able to deal...
For a nice, scattershot intro to bits of many kinds of CS-ish math, I recommend Godel, Escher, Bach by Hofstadter (if you haven't read it already, of course). It's not a formal math book, though, so it won't help you with the familiarity problem, but it is quite inspirational.
Mathematical notation is is akin to several computer languages:
concise
exacting
based on many idioms
a fair amount of local variations and conventions
As with a computer language, you don't need to "wash the whole elephant at once": take it one part a at time.
A tentative plan for you could be
identify areas of mathematics that are interesting or important to you. (seems you already have a bit of a sense for that, CS has helped you develop quite a culture for it.)
take (or merely audit) a few formal classes in this area. I agree with several answers in this post, an in-person course, at local college is preferable, but, maybe at first, or to be sure to get the most of a particular class, first self-teaching yourself in this area with MIT OCW, similar online resources and associated books is ok/fine.
if an area of math introduces too high of a pre-requisite in terms of fluency with notation or with some underlying concept or (most often mechanical computation and transformation techniques). No problem! Just backtrack a bit, learn these foundations (and just these foundations!) and move forward again.
Find a "guru", someone that has a broad mathematical culture and exposure, not necessarily a mathematician, physics folks are good too, indeed they can often articulate math in a more practical fashion. Use this guru to guide you, as he/she can show you how the big pieces fit together.
Note: There is little gain to be had of learning mathematical notation for its own sake. Rather it should be learned in context, just like say a C# idiom is better memorized when used and when associated with a specific task, rather than learned in vacuo. A related SO posting however provides several resources to decipher and learn mathematical notation
Project Euler takes problems out of context and drops them in for people to solve them. Project Euler cannot teach you anything effectively. I think you should forget about it, if it is popular it does not mean anything. You cannot study Mathematics through Project Euler as it contains only bits and pieces(and some pretty high level pieces) that you're supposed to know in order to solve the problems. Learning mathematics means to consider a subject and a read a book about it and solving exercices or reading solutions, that's how you learn math. If it so happens that through your reading you find something that is close to some project euler thing, your luck , but otherwise Project euler is a complete waste of time. I think the time is much better invested choosing a particular branch of mathematics and studying that. Let me explain why: I solved 3 pretty advanced Projec Euler problems and they were all making appeal to knowledge from Number theory which I happened to have because i studies some part of it. I do not think Iearned anything from Project Euler, it just happened that I already knew some number theory and solved the problems.
For example, if you find out you like number theory, take H. Davenport -> Hardy & Wright -> Kenneth & Rosen's , study those.
If you like Graph Theory take Reinhard Diestel's book which is freely available and study that(or check books.google.com and find whichever is more appropriate to your taste) but don't spread your attention in 999999 directions just because Project Euler has problems ranging from dynamic programming to advanced geometry or to advanced number theory, that is clearly the wrong way to go and it will not bring you closer to your goal.
This sounds amazingly boring
Well ... Mathematics is not boring when you find some problem that you are attached to, which you like and you'd like to find the solution to, and when you have the sufficient time to reflect on it while not behind a computer screen. Mathematics is done with pen and paper mostly(yes you can use computers .. but that's not really the point).
So, if you find a real-world problem, or some programming problem that would benefit from
you knowing some advanced maths, and you know what maths you have to study , it can be motivating to learn in that way.
If you feel you are not motivated it is hard to study properly.
There is also the question of what you actually mean when you say learn. Does the learning process stop after you solved the problems at the end of the chapter of a book ? Well you decide. You can consider you have finished learning that subject, or you can consider you have not finished and read more about it. There are entire books on just one equation and variations of it.
The amount of programming-related math that you can learn without formal training is limited, but it's more than enough. But maybe you can self-teach yourself.
It all boils down to your resources and motivation.
To know mathematics you have to do mathematics not programming(project euler).
For beginning to learn category theory I recommend David Spivak's Category Theory for the Sciences (AKA Category Theory for Scientists) because its relatively comprehensible due to many examples that enable understanding by analogy and which quickly builds a foundation for understanding more abstract concepts.
It requires the ability to reason logically and an intuitive notion of what is a set. It proceeds from sets and functions through basic category theory to adjoint functors, categories of functors, sheaves, monads and an introduction to operads. Two main threads throughout are modeling databases in terms of categories and describing categories with annotated diagrams called ologs. The bibliography provides references to more advanced and specialized topics including recent papers by Dr. Spivak.
An expected outcome from reading this book is the capability of understanding category theory texts and papers written for mathematicians such as Mac Lane's Category Theory for the Working Mathematician.
In PDF format it is available from http://math.mit.edu/~dspivak/teaching/sp13/ (the dynamic version is recommended since its the most recent). The open access HTML version is available from https://mitpress.mit.edu/books/category-theory-sciences (which is recommended since it includes additional content including answers to some exercises).

Where can I find math topics and resources for programmers?

There are a few questions around that circle around this question but I feel this is different enough.
I've decided I want to improve the breadth and depth of my maths skills specifically in areas that are useful and/or interesting to programmers.
What topics should I study?
What resources do you recommend (blogs/books/online lectures...)?
I'm looking for easy to consume resources because I'll be doing this in my free time, I don't want to spend days struggling through a dense text but I want to get deeper than the surface. I've read the Yegge article on the topic (and most of the comments) which is useful but I think the voting system here will help me focus on the most useful/best resources and topics.
Edit:
I am looking to create myself a study course that I'll follow over the next few years, I'm not looking to solve a particular problem I just want to learn some new skills that will interest me and may be useful in my career in the future.
Concrete Mathematics: A Foundation for Computer Science would be my suggestion for a book that covers some advanced topics.
For an introduction to Discrete Mathematics I strongly suggest this.
I feel very lucky to have been provided this book from University
Any programmer would do well to have a solid understanding on the undergraduate level of these following math courses:
Calculus (at through multivariate calc)
Discrete Mathematics (absolutely essential)
Linear Algebra (necessary for an understanding of matrices)
Combinatorics (further development of Dicrete maths)
Introduction to Abstract Algebra (this will solidify your understanding of modulo number systems, in particular binary, octal, hex etc.). It also gives a deep understanding of set theory which is ubiquitous in practical programming and the comp sci literature.
This is the fundamentals. If your are thinking about graphics or game programming then you have a whole slew of additional courses in physics, graphic arts, and possibly fluid dynamics. Also Differential Geometry is essential for any real world modeling of motion on curved surfaces.
It's a bit off from your question, but let me suggest the Princeton Companion to Mathematics.
It gives an overview of all of mathematics, so it is more than "math useful to programmers", but it's style is as easy to understand as it gets, and the important parts are in there.
Some time ago Steve Yegge wrote a dedicated article about math for programmers. His thesis is: As a programmer you should learn math but you should do so in different way than in shool/university.
His summary is this:
Math is a lot easier to pick up after you know how to program. In fact, if you're a halfway decent programmer, you'll find it's almost a snap.
They teach math all wrong in school. Way, WAY wrong. If you teach yourself math the right way, you'll learn faster, remember it longer, and it'll be much more valuable to you as a programmer.
Knowing even a little of the right kinds of math can enable you do write some pretty interesting programs that would otherwise be too hard. In other words, math is something you can pick up a little at a time, whenever you have free time.
Nobody knows all of math, not even the best mathematicians. The field is constantly expanding, as people invent new formalisms to solve their own problems. And with any given math problem, just like in programming, there's more than one way to do it. You can pick the one you like best.
Math is... ummm, please don't tell anyone I said this; I'll never get invited to another party as long as I live. But math, well... I'd better whisper this, so listen up: (it's actually kinda fun.)
Sad note: Steve abandoned his blog because of too much aggressive feedback.
If you have any interest in game development, 3D graphics, or anything somewhat related to those, then do multivariate calculus and basic physics. This will help you understand the basic concepts much better. Also, linear algebra will help immensely with all of the matrix/vector stuff you will be doing.
If you are NOT interested in these topics, I would still say study calculus and physics. Why? Solving calculus and physics problems gives you good experience in problem solving and exercises the brain. Programmers NEED to be good problem solvers... that is our job. Concepts you pick up from these courses are things you will keep with you the rest of your life.
MIT and Stanford both have really good online courses for topics such as this. Of course you can't just jump into multivariate calculus without some more basic calc, but MIT and Stanford have resources for your basic calculus classes as well. Basic physics will be a little bit easier to pick up. Again, you can check MIT and Stanford for physics.
MIT OpenCourseWare:
Single Variable Calculus
Calculus
Multivariable Calculus
Physics I: Classical Mechanics
Mathematics for Computer Science
Generally speaking, the applications of math to computer programming are pretty domain-specific - that is, you need to know whatever math the specific program you're writing requires. The only mathematical topics I can think of that are generally applicable to all kinds of programming are simple arithmetic and boolean logic, but I think if you didn't already know those you wouldn't be much of a programmer ;-)
Basically, I would just recommend learning the math as needed for whatever project you're working on. If you want to give yourself a good excuse to learn some new math, start a hobby program that does something mathematical.
As for topics, look at some of the answers here. Recommended ressources are difficult for me to give, I'm German speaking. I would recommend starting with linear algebra and geometry, which you will find in computer graphics. Look at the undergraduate math series by Springer for example.
Number theory doesn't have many direct applications to programming (though there are some neat tricks you can use for optimization), but there are several basic concepts that make cryptology much easier to study.
My number theory class used Silverman's Friendly Introduction to Number Theory, which is one of the best math textbooks I've ever seen. It's very easy to read (the title is entirely accurate about its friendliness), but covers a wide range of topics. Silverman is also an author on my cryptography textbook, An Introduction to Mathematical Cryptography. It's more technical, addresses most areas of cryptography, and provides plenty of references for where to find more detail.
Consider Knuth's Art of Computer Programming series. It can get dense, but it will ground you in the math most needed for programming. I'd suggest going for the available fascicles of Volume 4 early on. These books are not for everybody, but if you find them interesting you will learn a whole lot.
They won't teach you calculus or geometry, which are important in many aspects of programming but tend to be more specialized.
I think you should dive into whatever interests you most and in order to find out what that is you should get some books which cover the facts and offer orientation and some books which nurture your motivation and curiosity. You really have to dive into it to find out, it's a pretty individual thing imho.
Facts / Orientation:
Donald Knuth -
Bronstein, Semendjajew
The Science of Programming -
Data Structures and Algorithms
Motivation / Curiosity:
The Road to Reality -
Fermat's Last Theorem -
Godel, Escher, Bach
Also for motivation on the more practical side:
projecteuler.net
What sorts of math problems do you want to solve? 'Math' is a pretty big area!
MIT has some online courses, but that's probably a big time investment.
Wolfram has some tutorials, but again, you need to know what you're looking for.

Math, programming, and learning [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
It has been discussed on this site before about the relationship between math and programming, and whether one is a subset of the other, etc.
In my recent study of programming, I've found myself more and more wishing I was better at math. You all know the scenario when programming books start to generalize something in a math way ("Therefore, we may say that for all <some single letter>, <lots of letters>"). My eyes glaze over in such situations. I know that that is mostly due to me being stupid, but it seems that if I could just improve my higher math skills, maybe I could get more out of such things.
Major question: Is math indeed something one can "get better at," or is your brain kinda either wired for it or not?
Important follow-up question: If the answer to the above is yes, then what are some ways to go about it?
I think anyone can get better at math. You just have to be determined and practice.
Part of the problem is that math books tend to be written by mathematicians who ceased being math novices decades ago. What you want is books geared to your level and which contain material you can work with.
Some recommendations:
If you can find a copy, get Mathematica and a good book on it (the Schaum's outline is actually pretty good and cheap). I use it all the time to visualize things.
As a programmer, you probably want to aim more for discrete mathematics than calculus.
The Concrete Mathematics book mentioned elsewhere is excellent.
Most introductory discrete math texts have good coverage of the things like logic, sets, combinatorics, probability, graph theory, etc. My school used Rosen's text which I liked.
Linear algebra is useful if you are going to do 3D graphics programming. Most intro texts for engineers will teach you what you need to know. Linear Algebra Done Right is probably the best on "real" linear algebra if you want something more theoretical.
Look for books by Martin Gardner and play with his puzzles. He's an excellent writer and teacher.
Remember that math doesn't change that much. You can get used books for cheap on Amazon and in used bookstores. I always look for the n-1 version when I buy textbooks.
When you first started learning English all those "symbols" (letters) looked like gibberish to you. I'm sure that at some point you were frustrated over your lack of understanding. But slowly, and gradually you began to understand them.
Eventually you were able to construct your own words and sentences using these symbols. After being corrected on it's structure and grammar for years you now have a command of the language.
Math is just like that. Your eyes glaze over because you haven't learned the language. Maybe in school you didn't particularly enjoy math because you didn't see any practical applications for it. Certainly the way we teach math to our students is atrocious, so it is no wonder why many get through school without being well versed in it (for further reading, check out A Mathematician’s Lament which discusses how horrible our current method of teaching math is).
However, it is never too late to get up to a degree of proficiency that will allow you to read many academic Computer Science writings. Start out with Pre-Calculus at your local community college at night (to brush up on everything you have forgotten). Then move on to Calculus and after that take Discrete math. Honestly, this is all the math you will need 99.99% of the time. In less than 2-3 semesters you can be fully caught up and you'll no longer have your eyes glaze over when reading something with some mathematical roots.
I can share my experience...
I have been terrified of math since grade school. Hated it, didn't get the point, didn't pursue it.
By contrast, I have always been fascinated by computers. I study programming from a "need to know"- I can't stand not understanding computers and programming from the lowest to highest levels. I am almost completely self-educated, and have a career as a programmer/architect.
Last year, at my wife's urging, I began to go back to college. I signed up for a remedial Algebra class, knowing it was going to be a pain. It wasn't.
Somehow, through all the years of learning to develop OO software, it seemed that I had tricked myself into learning how to think mathematically. The concepts just weren't that difficult anymore. It may be that I had learned to think in terms of complex systems made up of smaller, less complex ideas.
I am now researching game development, and that is some seriously math-oriented programming. WAY more so than the business development I've been doing to this point. However, I don't find it so daunting because it's applied mathetmatics. Working to solve practical problems seems to make the study less tedious and far more interesting. I have found Wikipedia and Wolfram's Mathworld to be helpful. If you already know how to program, you're ahead of the game learning math.
I'd say it's certainly something anyone can get better at. It takes time and patience and some texts are obscenely dense as far as the notation involved, but if you're willing to put the time in, I think it shouldn't be too horrible.
I'd check out Wikipedia's list of mathematical symbols, and keep if nearby whenever you see a large blob of symbols pop up. Translate them one at a time and put them together in the way that makes the most sense to you (or ask us a few times until you get the hang of it).
It's both. You can get better at math. But you're also indeed limited/endowed by the particular wiring in your brain. What that means is that most likely you can improve your current mathematical skills. However, because of your mental hardware's limits, you may never discover a new theorem.
And when it comes to improving, I think the way as always is to practice. To read mathematical literature, to try to solve mathematical problems and eventually, develop an outlook where you are able to break, as a matter of habit, real-world conundrums you see before you down in mathematical terms.
As for programming's relation with mathematics, I think there's a pretty strong one. In fact, one could argue that a program is nothing but a proof of a theorem, the requirements document being all the inputs to the proof.
Your skills get rusty if not used and knowledge fades with time if not used.
If you don't use your math skills you soon have no math skills. Continuous new learning and practice of the skills you already have will lead to you one day being a math/programming master.
Project Euler has lot of math problems that can only be solved through programming. The problems get more difficult but build on the skills and knowledge acquired in your previous solutions.
I also buy some interesting textbooks at second hand book shops. Their cheap and slowly your skills improve. I use them in conjunction with MIT Open Course ware.
A fun way to practice math is http://projecteuler.net/.
Although it's less systematic/effective than doing a course or reading a textbook.
I know exactly how you feel. I've always wanted to learn more Math, but as I was unable to do it at college after school (not enough space) and not able to take it at university (not able to with a CS degree) I'm still yet to study Math formally since the age of 16.
Math is something that anyone can learn. Some will argue that it gets harder with age but I've met people going on for 60 that are taking Math classes with ease. There's one woman at my university that's going on for 70 and she's a few months off of graduating with a degree in a Mathematics related field. If you want to learn Math then now is the right time, although I'll be the first person to say that it is not easy. Whilst you'll find many of the problems extremely easy with programming experience you'll still find that going through a set of problems takes a lot of time out of your day. I almost finished the MIT OpenCourseWare course on Linear Algebra, then ended up getting a new part-time job, working 10 hours a day, 7 days a week, and forgetting the majority of what I had learnt.
That being said, if you have the time and true dedication I can recommend some links to video lectures that may just help you get on your way.
Pre-Calculus Algebra
Pre-Calculus
Calculus
Applied Probability
Introduction to Statistics
Differential Equations
Linear Algebra
I'm not saying that this is what you need to know. This is what I've set out to learn myself before I graduate from my CS degree, so feel free to pick and choose whatever you feel is best for you.
Studying math is like getting a classical education, one specially suited for programmers and other computer professions. And math's the sort of thing that you can appreciate more as you get older. You realize that it's not about grinding out answers so much as it's about thinking deeply and conceptually. The "answers" you might grind out make a lot more sense that way.
At one time, I would have recommended taking a geometry course, and take some time to learn how to prove theorems, see how the concepts flow together. These days, though, I'd say it may be better to take a course in discrete mathematics. It's much more practical, and there's a lot more variety, but there's still enough theory in there to make it challenging if you want.
Discrete math also provides you with programming challenges you might not have thought of before. Maybe you can hack up a good heuristic to solve an NP-complete problem, like an N-city Traveling Salesman problem. Maybe even come up with a couple solutions, and test which ones work best in which circumstances.
(I never took CompSci classes in college. You can probably tell.)
Go to the local community college and sign up for Calculus 1. This covers functions in the mathematical sense, and has a rigorous refresher course on algebra, and will use just enough of the symbols to get you ahead.
First of all, I would recommend Steve Yegge's Math For Programmers. It pretty much sums up your struggle.
And now I would like to tell a personal story. I was a double major in Math and CS. I learned a lot in the Math classes, but I honestly didn't appreciate it as much as I should have. I will tell you that a lot of things that I did have helped me in my programming career. And it's not about some formula or knowing calculus, or any of that stuff. It's that a solid Math background teaches you how to think in order to solve a problem. To me, that's the Math that you need.
1) Yes.
2) Explore mathematical questions which sound interesting. Buy/read books that give you the information needed. Repeat.
It can absolutely be learned. I personally had the most benefit from the math (especially proof) courses I took in college.
Recommended courses:
Discrete Math
Mathematical Thought
Abstract Algebra
any other proof courses
Recommended book:
The Nuts and Bolts of Proofs, by Antonella Cupillari
I strongly recommend trying to take one or more of these courses at a school of some sort. Find a local college and audit a course.
A 2nd vote for Lockhart's "A Mathematician’s Lament", which recommends that math be taught like painting, poetry, or music -- not for it's practical usefulness but for simple pleasure:
There’s no
ulterior practical purpose here. I’m just playing. That’s what math is— wondering, playing,
amusing yourself with your imagination.
Look at the diagrams in a recent Knuth paper, Dancing Links, and tell me he wasn't having fun making those.
Part of the problem is that a few mathematical symbols convey a heck of a lot of information. If you are reading a normal programming book, it is full of words and code. Neither of these is super verbose (although I often have to slow down much more on code than normal words). However one complicated mathematical equation can easily be a screen full of programming code or words. We have all sorts of simple notations that convey complex processes.
Another issue is that notation is standardized but not exactly. Different books use slightly different notation so it takes a while to get used to it. Also many textbooks leave out key steps in mathematical proofs or even examples. Sometimes even college professors puzzle themselves with the missing steps in a given proof in a textbook and then give their own proof, or give a slightly modified one over the one in the book because they learned it differently or can't recreate the missing step exactly which takes the proof in a different direction.
So anyway just because your eyes glaze over doesn't mean you have to give up. The first time you see the equations you will probably be in read the english text mode and have to pause to consider them. Going over them slowly and paying attention to what all the symbols mean one step at a time may yield the answer for you. If there is some notation you haven't seen before, there is probably an intro chapter or appendix explaining the notation, so check there. Finally, look for other sources. Use google/wikipedia to look up equations for the concept and you may find a derivation and/or proof that you can follow. Additionally the other one may help you to understand the current proofs/derivations better. Even if your understanding of the proof/derivation does not improve, your additional research will probably aid in your understanding of the equation.
I think there are two things to learning math:
1. Learning the general techniques. Ie how to add two fractions, how to differentiate, integrate.
2. Learning to problem solve and apply math to the real world.
I think by picking up math textbooks yo will learn 1. Many math textbooks are organized by section where there will be a few pages showing you a technique and then a bunch of problems. The problems tend to be related to the technique that you just learned and very similar. Ie a section on logarithms will have all problems on logarithms and probably won't include any polynomials. By doing the problems in the section you will learn the techniques. The more problems you do the faster you will get and the more you will understand the concepts. Many times you will find if you work through the problems without explicitly memorizing the formulas, you will find that after you do enough the required formulas will be implicitly memorized. Ultimately if you are having trouble looking at probability formulas you will want to read a probability book. If you are having trouble with sum notation you will want to consult that section of an algebra book, etc...
To learn 2 I think math textbooks don't help as much because each section tends to have problems related to that section. Occasionally there are a few "mixed review" problems or a "chapter review" which mixes problems, but they are typically far in between. Science textbooks like Physics, Biology, Chemistry, etc. tend to be better for this. There you often read the problem, lay it out, and end up using a variety of mathematical tools to to solve it. Sometimes calculus, linear algebra, and geometry all within the same problem. The value here is that it teaches you to problem solve. Generally the SAT/GRE do not test if you know how to do Algebra, they test if you know how to apply it to the real world, and the science problems really help you here. Also programming in general is about problem solving and the better you get at problem solving the better you'll be at programming. Basically in programming you take problems, create a mental model, design a solution, and then model it in your programming language of choice. This is similar to say Physics. You look at the problem, extract a mathematical model, design a solution, right down some equations with the model of the solution, then plug numbers in. I highly recommend physics because after my college physics class word problems became simple for me and they used to be quite difficult (though not impossible).
In day to day programming you probably won't use more than algebra and logic (for if statements and loop conditions). There are some places that use high math like computer games, cryptology, data mining, etc. but for a typical business application you probably won't use more than algebra and logic and maybe a bit of set theory (the stuff so basic you already internalized it). Even in places that use high math (like financial companies) often the business users (or some industry literature) will have done the higher math and you will just need to implement the equations (with some algebra). I only mention this because most programming books don't have more than algebra and logic either, unless you are reading textbooks on Algorithm Analysis (Introduction to Algorithms), Artificial Intelligence, or some other research area. General application books on how to do things are usually short on math.
But depending upon what you are reading math can help. For most computer science algebra + discrete math should be enough. Couple that with some physics practice and you should be good to go. It may still be a slow go but you should have the proper background.
I like combinatorics and algorithms - having fun you learn faster.
study study study!
wikipedia is actually a fairly good math reference. start with something you're interested in learning and follow links until you understand all the building blocks for that initial thing.
practice practice practice!
Schaum's outlines are good for this. If you're interested in probability (which touches on combinatorics), see 50 Challenging Problems in Probability.
Short answer:
There may be people who are to stupid to get good a maths. But those people generally are to stupid to program, too.
So if you have some skills in programming, you might consider yourself smart enough to learn maths as well.
Note: I know there are smart people with a serious math learning disability, but I think thats more like an exception.
I would also recommend project euler While it does not exactly teach math, it gives you problems that you can then look up how to solve. I've always preferred solving actual problems instead of just learning theory.

Is programming a subset of math? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I've heard many times that all programming is really a subset of math. Some suggest that OO, at its roots, is mathematically based, but I don't get the connection, aside from some obvious examples:
using induction to prove a recursive algorithm,
formal correctness proofs,
functional languages,
lambda calculus,
asymptotic complexity,
DFAs, NFAs, Turing Machines, and theoretical computation in general,
and the fact that everything on the box is binary.
I know math is very important to programming, but I struggle with this "subset" view. In what ways is programming a subset of math?
I'm looking for an explanation that might have relevance to enterprise/OO development, if there is a strong enough connection, that is.
It's math in the sense that it requires abstract thought about algorithms etc.
It's engineering when it involves planning schedules, deliverables, testing.
It's art when you have no idea how it's going to eventually turn out.
Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians.
--E. W. Dijkstra
Overall, remember that mathematics is a formal codification of logic, which is also what we do in software.
The list of topics in your question is loaded with mathematical problems. We are able to do programming on a fairly high level of abstraction, so the raw mathematics may not be staring you in the face. For example, you mentioned DFAs.. you can use a regular expression in your programs without knowing any math, but you'll find more of a need for mathematics when you want to design a good regular expression engine.
I think you've hit on an interesting point. Programming is an art and a science. There are a lot of "tools of the trade", and you don't necessarily sit down and do a lot of high-level mathematics in order to simply write a program. In fact, when you're programming, you many not really being doing much mathematics or computer science.
It's when we start to solve difficult problems in computer science that mathematics shows up. The deeper you go, the more it will flesh itself out.. often in lower levels of abstraction.
There are also some realms of programming that you don't necessarily have to work in, but they involve more math. For example, while you can certainly learn a language and write some apps without any formal mathematics, you won't get very far in algorithm analysis without some applied math.
OK, I was a math and CS major in college. I would say that if the set A is Math and the set B is CS, then A intersects B. It's not a subset.
It's no doubt that many of the fathers and mothers of computer science were Mathematicians like Turing and Dykstra. Most of the founders of the internet were either Phd's in Math, Physics, or Engineering. Most of the core concepts of computer science come from math, but the act of programming isn't really math. Math helps us in our daily lives, but the two aren't the same.
But there is no doubt that the original reasoning behind the computer was to well, compute things. We have come a long way from there in such a short time.
Doesn't mention programming, but idea is still relevant.
Einstein was known in 1917 as a famous mathematician. It wasn't until Hiroshima that the general public finally came around to the realization that physics is not just applied mathematics.
When people don't understand something, they try to understand it as a type of something that they do understand. They think by analogy. Programming has been described as a field of math, engineering, science, art, craft, construction... None of these are completely false; it borrows from all of these. The real issue is that the field of programming is only about 50 years old. People have not integrated it into their mental taxonomies.
There's a lot of confusion here.
First of all, "programming" does not (currently) equal "computer science." When Dijkstra called himself a "programmer" (more or less inventing the title), he was not pumping out CRUD applications, but actually doing applied computer science. Let's not let that confuse us-- today, there is a vast difference between what most programmers in a business setting do and computer science.
Now, the argument can be made that computer science is a branch of mathematics; but, as Knuth points out (in his paper "Computer Science and its Relation to Mathematics", collected in his Selected Papers on Computer Science) it can also be argued that mathematics is a branch of computer science.
In fact, I'd strongly recommend this paper to anyone thinking about the relationship between mathematics and computer science, as Knuth lays out the territory nicely.
But, to return to your original question: to a practitioner, "enterprise/OO development" is pretty far removed from mathematics-- but that's largely because most of the serious mathematics involved at the lower levels of operation have been abstracted away (by compilers, operating systems, instruction sets, etc.). Similarly, advanced knowledge of the physics of the internal combustion engine are not required for driving a car. Naturally, if you want to design a more efficient car....
if your definition of math includes all forms of formal logic, and programming is defined only by the logic and calculations extant in the code, then programming is a subset of math QED ;-)
but this is like saying that painting is merely putting colored pigments on a surface - it completely igores the art, the insight, the intuition, the entire creative process
one could argue that music is a subset of math by the same reasoning
so i'd have to say no, programming is not a subset of math. Programming uses a subset of math, but requires non-math skills/talent as well [much like music composition]
Disclaimer: I work as an IT consultant and develop mainly portals and Architecture stuff. I have a Psychology degree. I never studied Maths in University. And i get my job done. And usually well. Why? Because I don't think you need to know Maths (as in 'heavy' Maths stuff) to write code. You need analytical thinking, problem-solving skills, and a high level of abstraction. But Maths does not give you that. It's just another discipline that requires similar skills. My studies in Psychology also apply to my daily work when dealing with usability issues and data storage. Linguistics and Semiotics also play a part.
But wait, just don't flame me yet. I'm not saying Maths are not needed at all for computers - obviously, you need real Math skills when designing encryption algorithms and hardware and etc -- but if, as lots of programmers, you just work an a mid/low level language (like C) or higher level stuff (like C# or java), consuming mostly pre-built frameworks and APIs, you don't really need to understand the mathematical principles behind Fourier transforms or Huffman trees or Moebius strips... let someone else handle that, and let me build value on top of it. I am not stupid. I know the difference between linear and exponential algorithms and data structures and etc. I just don't have the interest to rewrite quicksort or a spiffy new video compression technique.
Well, aside from all that...!
Math is used for many aspects of programming such as
Creating efficient and smart algorithms
Understanding Big O notation
Security (such as RSA)
Many more...
I think that programming needs math to survive. But I wouldn't call it a subset. It's just like blowing glass uses properties of physics, but those artists don't call themselves physicists.
The foundation of everything we do is math.
Luckily, we don't need to be good at math itself to do it. Just like you don't need to understand physics to drive a car or even fly a plane.
The difference between programming and pure mathematics is the concept of state.
Have a look at http://en.wikipedia.org/wiki/Dynamic_logic_(modal_logic). It's a way of mathematically analyzing things changing through time. Also, Hoare triples is a way of formalizing the input-output behavior of programs. By having some axioms dealing with sequential composition of programs and how assignment works, you can perfectly well deal with state changing over time in a mathematically rigorous way.
If the math you know is insufficient, "invent" some new math to deal with what you want to analyze. Newton and Leibniz did it for analysis (aka calculus, I think). No reason to not do it for computation and programming.
I don't believe I've heard that programming is a subset of math. Even the link you provide is simply a proposed approach to programming (not claiming it's a subset of mathematics) and the wiki page has plenty of disagreements in it as well.
Programming requires (at least some) applied mathematics. Mathematics can be used to help describe and analyze programs and program fragments. Programming has a very close relationship with math and uses it and concepts from it heavily. But subset? no.
I'd love to see someone actually claim that it is one with some clear reasoning. I don't think I ever have
Just because you can use mathematics
to reason about something does not
imply that it is, ipso facto, a
mathematical object. Mathematics is
used to reason about internal
combustion engines, radioactive decay
and juggling patterns. Using
mathematics is not doing mathematics.
I would say...
It's partly math, especially at the theoretical level. Imagine designing efficient searching/sorting/clustering/allocating/fooifying algorithms, that's all math... running the gamut from number theory to statistics.
It's partly engineering. Complex systems can rarely achieve ideal levels of performance and reliability, and software is no exception. A lot of software development is about achieving robustness in the face of unreliable hardware and (ahem) humans.
And it's partly art. Creative and idiosyncratic software design often comes up with great new ideas... like assembly language, multitasking operating systems, graphical user interfaces, dynamic languages, and the web.
Just my 2¢...
Math + art + logic
You can actually argue that math, in the form of logical proofs, is analogous to programming --
Check out the Curry-Howard correspondence. It's probably more the way a mathematician would look at things, but I think this is hitting the proverbial nail on the head.
Programming may have originally started as a quasi-subset of math, but the increasing complexity of the field over time has led to programming being the art and science of creating good abstractions for information processing and computation.
Programming does involve math, engineering, and an aesthetic sense for good design and implementation. Algorithms are an extension of mathematics, and the systems engineering side overlaps with other engineering disciplines to some degree. However, neither mathematics nor other engineering fields have the same level of need for complex, flexible, and yet understandable abstractions that can be used and adapted at so many different levels to solve new and evolving problems.
It is the need for useful, flexible, and dynamic abstractions which led first to the creation of function libraries, then class/component libraries, and in more recent years design patterns and service-oriented architectures. Although the latter have more of a design focus, they are a reaction to the increasing need to build high-level abstractional bridges between programming problems and solutions.
For all of these reasons, programming is neither a subset nor a superset of math. It is simply yet another field which uses math that has deeper roots in it than others do.
The topics you listed are topics in Theoretical Computer Science, and THAT is a branch of Pure Mathematics. Programming is an applied science which uses theoretical computer science. Programming itself isn't a branch of mathematics but the Lambda Calculus/theory of computation/formal logic/set theory etc that programming languages are based on is.
Also I completely disagree with Dijkstra. It's either self-congratulatory or Dijkstra is being misquoted/quoted out of context. Pure mathematics is a very very very difficult field. It is so enormously abstract that no branch of applied mathematics is comparable in difficulty. It is one field that requires enormous leaps of imagination. I did my first degree in computer science where I focused a lot on theoretical CS and applied areas like programming, OS, compilers. I also did a degree in Electrical Engineering - arguably the most difficult branch of engineering - and worked on difficult areas of applied mathematics like Maxwell's equations, control theory and partial differential equations in general.
I've also done research in applied and pure mathematics, and to this day I find applied far easier. As for the pure mathematicians, they're a whole different breed.
Now there's a tendency for someone to study an year or two of calculus unhinged from application and conclude that pure mathematics is easy. They have no idea what they're talking about. Studying calculus or even topology unhinged from application does not give you any inkling of what a pure mathematician does. The task of actually proving those theorems are so profoundly difficult that I will defer to a computer scientist to point out the distinction:
"If P = NP, then the world would be a profoundly different place than we usually assume it to be. There would be no special value in 'creative leaps,' no fundamental gap between solving a problem and recognizing the solution once it’s found. Everyone who could appreciate a symphony would be Mozart; everyone who could follow a step-by-step argument would be Gauss..." —Scott Aaronson, (Theoretical Computer Scientist, MIT)
I think mathematics provides a set of tools for programmers which they use at abstract level
to solve real world problems.
I would say that programming is less about math than it used to be as we move up to 4th Generation Languages. Assembly is very much about math, C#, not so much. Thoughts?
If you just want the design specs handed out to you by your boss, then it's not much math but such a work isn't fun at all... However, coming up with how to do things does require mathematical ideas, at least things like abstraction, graphs, sometimes number theory stuffs and depending on the problems, calculus. Personally, more I've been involved with programming, more I see the mathematical side to it. However, most of the times IMO, you can just pick up the book from library and look up the basics of the thing you need to do but that requires some mathematical grasp upfront.
You really can't design "good" algorithms without understanding the maths behind it. Searching in google takes you only so far.
Programming is a too wide subject. Good software based not only on math (logic) but also on psychology, linguistics etc. Algorithms are part of math, but there are many other programming-related things besides algorithms.
As a mathematician, it is clear to me that Math is not equal to Programming but that the process which is used to solve problems in either discipline is extremely similar.
Solving a higher level mathematics questions requires analytical thinking, a toolbox of possible ways of solving problems, experience with the field, and some formalized ways of constructing your answer so that other mathematicians agree. If you find a particularly clever, abstract, or elegant way of solving a problem, you get Kudos from your fellow mathematicians. For particularly difficult math problems, you may solve the problem in stages, and codify your stage arguments using things called conjectures and proofs.
I think programming involves the same set of skills. In programming, the same set of principles applies to the solving and presenting of solutions to problems. When you have a partial solution to a programming dilemna, you include it as part of your personal library and use it as part of another bigger problem later. These skills seem very similar to the skills used in mathematics.
The major difference between Math and Programming is the latter has a lot more in common between different disciplines of programming than Math does. Two fields of mathematics can be very, very different in presentation and what is used to communicate the field. By contrast, programming structures, to me at least, look very similar in many different languages.
The difference between programming and pure mathematics is the concept of state. A program is a state machine that uses logic (maths) to transition between states. The actual logic used to transition between states is usually very simple, which is why being a math genius doesn't necessarily help you all that much as a programmer.
Part of the reason I'm a programmer is because I don't like math. I have no problem with math itself, and I'm fine with it conceptually, I just don't like doing calculations by hand. When I found I could tell a computer what the math problem is and let it do the calculating for me, a life-long passion and career was born.
To answer the question, according to my alma mater, math == programming since they allowed me to take Intro to C++ to fulfill my math requirement.
Edit: I should mention my degree is in telecommunications which, at the time, had only the standard liberal arts math requirement of one semester.
Math is the purest form of truth. Everything inherits from math.
Amen.
It's interesting to compare programming with music too. In UK, anyway, there are computing based undergrad university courses that will accept applicants on the bases of music qualifications as supposed to computing due to the logic, patterns, etc. involved.
Maths is powerful, programming is powerful, if maths is a subset of programming then it is equally true to state that programming is a subset of maths.
Maths is described using language, often written down. Therefore is maths a subset of writing too?
Historicly maths came before computer programming, but then lists and processes probably preceded maths, both of which could be equally thought of as mathematical or do with programming.
Cirtainly programming can be represented using maths, so there is some bases for it being true that programming is a sub-set of maths. However a computer program could also implement maths, representing information symbolically, as maths typically does when done on paper, including the infinite and only somewhat defined, from the fundamental axioms, as well as allowing higher level structures to be defined that use each other and other sorts of relationships beyond composition, supporting the drawing of diagrams and allowing the system to be expanded. Maths is equally a subset of programming.
While maths can represent structures such as words, maths is by design about numbers. Strings for example are more programmatic than mathematic.
It's half math, half man speak, duh.

Resources