views:

1462

answers:

16

Hi everyone,

I was just wondering about math as a programmer. I DO use math a fair bit, mainly vector math and occasionally trigonometry when I do games programming.

My question: Do you consider there to be any essential math that you as a programmer must know in order to be a successful (and awesome) programmer? Mainly I have found that programming is just logic, but there may be times when clever math can (not algorithms specifically) can be used to work around common problems.

+3  A: 

Game programming aside, basic Algebra is enough to get you by in pretty much anything else.

Still I enjoyed the time I spent learning Calculus. But I'm unsure why I had to take such an in-depth statistics class.

Spencer Ruport
Stats are super helpful when you're doing perf testing and runtime comparisons. cf. http://www.zedshaw.com/rants/programmer_stats.html
wulong
Plus, assuming you went to a University for Comp Sci. and not a tech school for programming, stats are just one of those "well-rounded scientist" type of things. University is not (or should not) be just about teaching you practical day to day programming skills.
nezroy
It's kind of irrelevant now but at the time I felt that time would have been better spent learning about other things that weren't "practical day to day programming skills" either.
Spencer Ruport
I find that combinatorics come up surprisingly often, as well.
Pavel Minaev
+2  A: 

See this question for useful information: http://stackoverflow.com/questions/420500/helpful-math-classes-for-programmers

RexE
+4  A: 

Read the book "How to solve it by computers" by R.G.Dromey.It will help you in problem solving.

Warrior
+3  A: 

Basic addition, subtraction, multiplication and division are the first things that come to mind.

An understanding of modular arithmetic is certainly helpful along with all of the associated identities especially when dealing with expressions or situations that might produce or that quickly grow beyond the capacity of the basic integer types. A good example of this is taking the modulus of something raised to a ridiculously large power (e.g. 2^345 % 6789).

Knowing how to convert between bases as well as understanding how a number is represented in a base. Trigonometric and logarithmic identities are also incredibly handy for some problems. Also (and I'm not sure if you can count this as math) an understanding of how bit-wise operators work and for that matter boolean algebra in general.

I have on occasion found that at least a basic understanding of calculus can have applications in the most unlikely of places (not so much integration but definitely derivation). A good example of this is the 'magic' inverse square root function from the quake engine which is pretty much just one iteration of the Newton-Raphson algorithm.

Kevin Loney
+2  A: 

I had a lot of math during my study:

  • Basic algebra
  • Linear algebra (matrices)
  • Descrete mathematics
  • Probability math
  • Cryptography
  • Coding theory
  • Mathematical logic

At that moment I didn't like it, but now I am thankful because it really helps me doing my job.

Gamecat
+1  A: 
  1. Linear Algebra - you need this for physics, accounting, really most business logic.
  2. Logic - knowing how the associative and distributative rules apply to booleans has helped me debug code sooo many times.
  3. Tuple Calculus - SQL (a language for interacting with databases) is based on tuple calculus; even if you only understand the basics, you're so far ahead of everyone else in the "real world" that all their database code will look simplistic

That's it. If I had known how important Tuple Calculus would be to anyone writing or debugging any sort of database code, I would have tried to teach myself in high school. Way more important than any C, C++ or Java courses I took.

Rick
+5  A: 

Check Math for Programmers a really good article.

CMS
+26  A: 

I think it can be more subtle than just the obvious 'Essential Maths'. I've done a fair amount of graphics coding - 2D and 3D, mainly non-gaming, quite a lot heavily fractal-based - and got by fine on the maths I'd been taught at college plus self-education of anything else I needed (like most coders I guess I'm pretty good with maths) - so the usual Linear Algebra, Logic, Basic Calculus etc - and I've never felt particularly constrained by what I knew or could teach myself.

However at one point I had the opportunity to work with a young guy who'd just done a joint maths/computing degree to develop an atmosphere engine (one that models light decay and other atmospheric/light interactions). What particularly impressed me was his familiarity with a vastly wider range of mathematical functions than a 'normal' coder - and consequently when a particular behaviour was required he was able to reach for a just the right mathematical function and implement that to solve a problem in hand. None of the maths he used was actually that complex - I could understand it fine when shown it - but rather because he knew his mathematical vocabulary with such depth and breadth he was able to reach for 'le mot juste' effortlessly whenever he needed it rather than floundering around looking for it like most of us.

So I have a suspicion that, certainly in some problem domains, and possibly a wider selection than is obvious, a greater familiarity with maths than is common knowledge would lead to the implementation of better algorithms. We may only see a problem in terms of the tools in the toolbox and don't actually realise we're missing anything we don't have.

Cruachan
+1 for the literary characteristic of your answer.
Dana the Sane
also +1 for a good example
Nathan Fellman
+5  A: 

I think it mostly depends on the project domain.

That's why game-programming usually requires knowledge in linear-algebra, quaternions, etc.

Programming is simply a means to achieve a certain end, and how much math you need to know is exactly the same as how much you need to understand the health-industry if that's your project domain.

Historically, Computer-Science is a branch of Applied Mathematics, and I think that's why there is such a strong connection between mathematics and programming. I think a mathematical mind is good to have as a programmer, but I'm not certain mathematical knowledge is a must in all fields.

Gilad Naor
A: 

Depends

Anything to do with datastructures, performance and optimisation requires maths to get really good results. In other word robust maths underpins most of the core programming libraries.

Generally though, most of us work at a higher level where we just have to tie all of these prebuilt systems together, and for us maths is optional, but not necessary.

Fergie

Fergie
A: 

well, I think a good programmer have to know some important math topics that involves logic, base calculus, and algebra and probability.

We have lots of important things to know, even logarithm is important for example to evaluate complexity of an algorithm, one important field usually do not covered even during academic classes is the arithmetic of floating points numbers, imagine a big system for managing transactions in a stock exchange, you cannot approximate anything, you have to manage and estimate errors, an error of 1 per million over millions of operations per day could result a big problem....

Lopoc
You refer to 'Numerical Analysis' - the study of computation with realistic (as opposed to Real) numbers. However, financial transaction software always uses whole units, or coded decimal. No one uses floating point for actually data recorded in ledgers.
Novelocrat
+1  A: 

Crucial, but only passingly mentioned above: graph theory.

Doug McClean
+1  A: 

It really depends on what you are doing.

Most stuff I've done needed nothing above multiplication. Even super complicated programs. Actually, even multiplication was rare. It's usually just addition and subtraction...

Now, if you start doing graphics, especially 3D graphics, you'll need a bit of maths. Luckily however there are some excellent tutorials on the internet. You absolutely DON'T need a University degree, rather just a few hours here and there reading tutorials and coding some experiments, to learn vector math and all that for 3D graphics.

boytheo
A: 

Concrete Mathematics has some good Mathematical concepts that apply to Computer Science in various ways if you want another book idea.

JB King
+1  A: 

In my experience, the basic math is the following:

0.- Floating point arithmetic
1.- Linear Algebra
2.- Vector (possibly Tensor) Analysis
3.- Linear Algebra
4.- Linear Algebra
5.- Linear Algebra

It could also be helpful if you know Linear Algebra.

Arrieta
A: 

I'm surprised no one mentioned abstract algebra. The notions of lists, string concatenations, functions (!), function chaining etc. all have their roots here.

Agos