开发者

what kind of programming requires math? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

开发者_如何学C

Closed 1 year ago.

Improve this question

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?


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.


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.


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.


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.


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.


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.


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


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.


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....


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

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


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.


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.


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.


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!


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.


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.


I got my masters degree in meteorology, and I can tell you for that field and other applied physics fields, the kind of coding you will be doing requires an immense amount of mathematics. A lot of what you are coding are things like time differential of equations.

For things like writing code for games, however, you're not always going to be doing a lot math in your code. Gaming requires lots of logic. The part of game coding where math comes in is when you have write physics engines and things like that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜