views:

920

answers:

17

This is not a "is math required for programming?" question.

I always thought that for programming, a scary amount of complicated math would be involved (I only got as far as intermediate algebra in college because I'm bad with it).

However, I just got my first job as a developer and have found there is not a ton of math above basic arithmetic(as of yet). I also read on a question here in SO that math is more used to ensure the would-be developer can understand complex problems and solve them.

So I guess is there a different kind of programming where a math level above algebra is needed? My guess would be like geometry and other disciplines for video game programming where you create shapes in 3D and play with time and space in environments. What else requires a high level of math?

EDIT: Wow, lot of answers. One of which made me think of another similar question...say in programs like photoshop, what kind of math(or overall work) is involved in making something twist, crop, edit, and color things like images?

+2  A: 

Quite alot of complex(ish) math in the Finance sector. Other than that and Trig for 3d I can't honestly think of much else.

Im sure there are some though.

Jamiec
+4  A: 

Game programming (especially 3-D, as you mentioned) has a lot of "more advanced" math. For that matter, any projects where you're modeling a system (e.g. physics simulation).

Crypto also uses different forms of math.

Jimmy
+1  A: 

Statistics is used heavily in businesses performing Quality Assurance and Quality Analysis. My first development job was on a contract at the USDA; these were standard "line-of-business" applications except their line-of-business happened to involve a lot of statistical analysis!

Stephen Swensen
A: 

Image compression and image recognition both use Fourier series (including classic sine wave series and other orthogonal series such as wavelet transformations) which has some pretty heavy theory usually not covered until a graduate level course in mathematics or engineering.

Non-linear optimization, constrained optimization, and system estimation using hidden models likewise use a significant amount of advanced mathematical analysis.

Ben Voigt
+2  A: 

Many seemingly non-mathematical industries such as Pharmaceuticals (eg. BioInformatics), Agriculture, Marketing and in general, any "Business Intelligence" relies heavily on statistics. System performance, routing, scheduling, fault tolerance -- the list goes on....

belwood
I even once was asked to write a routine to optimize distribution of notifications of repossessed cars to used car dealers. Math can happen anywhere!
belwood
+6  A: 

Any kind of numerical analysis, like in geophysics or petroleum exploration.

I once built a tool for accident investigators that required a lot of trigonometry.

In commercial programming, not so much math as arithmetic.

Gilbert Le Blanc
+6  A: 

Here's a few general places:

  • Graphics
  • Cryptography
  • Statistics
  • Compression
  • Optimization

There are also a lot of specific problem areas where complex math is required, but this is due more to the nature of the program and less about programming in general. Things like financial applications fall into this.

Alan Geleynse
+2  A: 

Digital signal processing and AI/simulation/agents are others.

Animation via code, especially when you try to model real physics, also needs math.

MPD
+30  A: 

I think there are at least two types of answer to this question. Firstly, there are the sorts of programming which is problems which come from a field where maths is important. These include:

  • finance
  • science research, e.g. physical modelling
  • engineering implementations, e.g. stress analysis, chemical engineering
  • experimental science, e.g. physics, psychology
  • mathematics itself
  • cryptography
  • image processing
  • signal processing

And then there are the sorts of programming where the target is not necessarily mathematical, but the process of achieving that target needs some maths. These include:

  • games
  • optimisation processes
  • high-complexity systems, e.g. flight control software
  • high-availability systems, e.g. industrial process monitoring and/or safety
  • complex data transformations, e.g. compiler design

and so on. Various of these require various levels and aspects of mathematics.

Tim
You should definitely put cryptography in the first bunch. It more right to be there than finance, for example.
Alin Purcaru
I guess you're right. :-) I've moved it now. Thanks!
Tim
I think it's worth mentioning that if you're hired as a developer on a project from the first group, the math will generally be handled by an expert of the field rather than assigned to the programmer. In my experience the programmer will probably just be assigned to translating matlab code or pseudo code into source code.
Graphics Noob
+1  A: 

I'm a Mathematics graduate and I have to say that the only places where I've really seen any Maths being used (above very basic arithmetic) is understanding / simplifying logical statements, so for example things like the equivalence of these two statements:

(!something) && (!otherThing)
!(something || otherThing)

Apart from that the only time that you would need more complex Maths is when you are working with computer graphics or some subject which is Maths based (e.g. finance or computations) - in which case knowing the Maths is more about understanding your subject than it is about the actual programming.

Kragen
+4  A: 

Robotics requires hardcore matrices, and AI requires all kinds of math.

Jon Rodriguez
+6  A: 

Gaming and simulation are obvious answers. The math is not difficult, but it is clearly there.

For example, say you want to build some sort of asteroids game. You'll need to figure out the position of your space ship. That's an vector. Now you want the ship to travel in a certain direction a certain direction every frame. You'll need to add some sort of delta-x to x, and delta-y to y, so your motion is another vector: . In an asteroids game, you accelerate in the direction you're pointing, so whenever you hit the 'thrust' key, you'll need to calculate the delta of dx and dy, or an acceleration vector,

(yep, this is the same dx from calculus class, but now I'm building robot zombie opposums with it.)

But that's not all. If you act now, I'll throw in some trig. Normally you think of motion and acceleration as angle and distance(r and theta,) but the programming language normally needs these values in dx, dy format. Here's where you'll use some trig: dx = r * cos (theta) and dy = r * sin(theta)

But, let's say you want to have a planet with a gravitational pull? You'll need to approximate gravity in a way that gives you orbit behavior (elliptical orbits, firing changes the altitude of the other side of the orbit, and so on.) This is easiest to do if you understand Newton's law of universal gravitation: f = ((sqrt(m1 * m2))/d^2) * G. This tels you how much 'planetward' force to add to your ship every frame.Multiply this value by a normalized vector pointing from the spaceship to the planet, and add that as a new motion vector.

Believe it or not, I encourage people who don't like math to take game programming courses. Often they discover that math can be (dare I say it) kind of fun when they're using it on problems that involve exploding cows in space.

As another example, think about optimizing a sound wave. The analog wave has an infinite number of points. It's impossible to store them all in a digital signal, so we break the audio signal into a large number of small segments, then measure every segment. If we want a perfect representation, grab an infinitely large number of infinitely small time slices.

Draw this out, and you've created the Riemann sum, the foundational idea of Integration (and in fact of Calculus)

One more example: A friend of mine (a biology professor) was trying to build a 'sim city'-style simulation of a lake ecosystem. He was a decent programmer, but he got all bogged down in the various calculations. He wanted the user to vary usage of the lake (outboard motors, fishing restrictions, and dumping restrictions) and then to see how that affected levels of Nitrogen and other key elements.

He tried all kinds of crazy if-then structures with nested conditions and ugly Boolean logic, but never had a clean solution.

We took actual data, ran it through Excel, and found a trendline that accurately reflected his data with a simple logarithmic formula.

Hundreds of lines of messy code were replaced with a simple formula.

Two pi
This would be enough to scare me away from programming were I not already where I am.
Gio
Well, like you said, much of the programming most coders work on doesn't require this stuff. If we start with math, we'll scare people away. The truth is, when people start looking at interesting problems, we can teach them to see math as the _SOLUTION_ rather than as a problem, and math actually becomes fun.
Two pi
yeah, you go from: "Hey make this ship move." "ok... lets see i can add some pixel values to it and it'll move, woot!" "Ok now make it acceleraet" "well if i tinker around a bit... hmm if i up the amount i move the pixels by, it moves faster, woot!" "Great now make it look realistic" "oh uh... i can tinker with it for like a few hrs..>" "Here's an easier way, check physics out:". I could program games before i knew basic physics but knowing the physics made it a lot easier to get good results.
Claudiu
I agree. What happens, though, is people have convinced themselves they don't like math and physics long before I meet them. When we play this way, what happens is people who thought they would never be interested in math or physics are ready to go take the classes, because they can see the utility.
Two pi
+5  A: 

All programming requires math. I think that the difference between people with mathematical backgrounds and people with programming backgrounds is how they approach and answer problems. However, if you are advancing your programming skills you are likely unknowingly advancing your mathematical skills as well (and vise versa).

If you abstractly look at both programming and mathematics you'll see they're identical in their approaches: they both strive to answer problems using very fundamental building blocks.

There is a pretty famous essay by Edsger W. Dijkstra which he attempts to answer your exact question. It is called: On the Interplay Between Mathematics and Programming.

evolve
+2  A: 

I work on software that's rather similar to CAD software, and a good grasp of geometry and at least an idea of computational geometry is necessary.

David Thornley
+2  A: 

I work in computational chemistry. You need a lot of linear algebra and general understanding of techniques such as Taylor expansion, integrals, gradients, Hessians, Fourier transformation (and in general, expansion on a basis set), differential equations. It's not terribly complex math, but you have to know it.

Stefano Borini
+1  A: 

Programming is math. (Lots of the time it's very easy math, but it's always math.)

Paul Reiners
A: 

Computer science is math. Programming is programmers job. They are related, but the two areas don't exactly overlap, so I see the point of your question.

Scientific computing and numerical analysis obviously require a solid base of linear algebra, geometry, advanced calculus and maybe more. And the whole study of algorithm, data structures and their complexity and properties makes use of discrete mathematics, graph theory, as well as calculus and probability. Behind the simple JPEG standard there's a lot of information theory, coding theory, fourier analysis... And these are only some examples.

Although a computer scientist could even work an entire life without writing down a single line of code, as well as the best programmer in the world could know just a little of math, the fact is that computers perform algorithms. And algorithms require math. I suggest you to take a look at Donald Knuth's "The Art of Computer Programming" to have an idea of what is underneath the "simple" programming thing.

Lorenzo Stella