tags:

views:

393

answers:

11

I'm not sure if this is for SO or not. I am reading some of my old math textbooks and trying to understand math in general. Not how to figure something. I can do that but rather what is it that math is doing.

I'm sure this is painfully obvious but I never thought about it until I thought more about game programming. Is it right to think about math as the "language" that is used to explain, precisely explain, why things work?

I'm having a hard time asking it and again, I'm sure it's obvious to most, but after years of math I'm finally thinking when someone asks to "find the equation of a line" that people recognized certain characteristics of a line (y=mx+b) in space and found relationship. They needed something beside a huge paragraph (like this one) and something very precise. We call this math and at its base it's nothing more than a symbolic way to represent things.

Really, I was thinking, "I know why they said 'find the equation of a line'."

So now I am thinking, not just googling for a formula that tells me how to turn a curve with a walking man or follow a path, but why and how do I represent this mathematically and then programatically.

Just hoping for comments on math in programming.

+1  A: 

I recommend that you look into materials related to the theory of computation. For example:

These are not papers for the faint of heart, but they will give you insights into the beautiful relationship between mathematics and computer science.

You might want to start with a textbook on the subject of computation theory before you tackle the papers listed above, e.g.

  • Introduction to the Theory of Computation - Michael Sipser
Brandon E Taylor
+4  A: 

To my way of thinking, I create a "model" of some aspect of the world. Examples:

  • Profit = Income - Expenditure
  • I throw a ball it's path will be a parabola with equation ...

I then represent the model in a computer program. So some kind of abstaction underpins the program, sometimes the math is so "obvious" we hardly notice it, sometimes (eg. simulation games) it's both very clearly there and pretty darn tricky.

Key idea: math can be used to model reality, most business systems can be viewed as represented as a model of reality.

Having said that, in 30 years of programming the amount of true (algebra, calculus) maths I have done is negligable.

djna
I agree - most of the math I've used in the past 15 years has been fairly elementary, except for some forays into trig. But then, I'm not writing fluid dynamics simulations, either...
GalacticCowboy
Of course it depends on the type of programming. As a web programmer I dont think anything beyond elementary math is needed. Doing CFD work on the other hand *requires* high level mathematics *and* numerical analysis.
ccook
A: 

I agree with Taylor. Math inside computers is a very deep topic with numerical methods. The biggest issues is precision and the fact that 32 bits only get you so far. There are some really cool (and complicated) functions that describe how to find integrals and such with computers, but because we can't be exact with our answers, and because computers are limited with what they can do (add, multiply, etc) there are lots of methods of how to estimate math to a great deal of precision.

If you are interested in that topic, all the more power to you. That was one class I struggled through.

RyanJM
I know in some languages (like Haskell), numbers are arbitrary precision; they enlarge as needed. Most languages have some kind of add-on if this is not built-in.
Lucas Jones
+4  A: 

Steve Yegge wrote a very good article that you may find helpful: Math Every Day

Nick D
this was a very good article. thanks.
johnny
A: 

I'm looking at something similar (financial models) - similar in that we come up with mathematical models, and then implement these in code.

The main issue you face from a programming perspective is taking a model that is expressed in mathematical terms (which assume continuity, infinitely small time/space steps etc.) and then translate these into 'discrete' models, that assume finite time/space steps (e.g. the ball moves every 1mm, or every 1ms).

The translation of these models is not necessarily trivial, and you should have a look at appropriate references for these (Numerical Recipes is a classic). The implementation in code is often very different to how you might express the problem in mathematical terms.

Brian Agnew
A: 

I think Math in programming with time, silence and good food such that I have a lot of paper and a pen, friends-to-ask-help and a pile of books from Rudin to Bourbaki on the top of my Macbook on the floor.

Masi
A: 

I think why is a philosophical question.

As far as how I think of math/programming and the interplay between... I think of them as layers of modeling. At the lowest, 'truest' level there is some fundamental truth, whatever that may be. Then there is the mathematical modeling of this truth, upon which the 'language' of mathematics is developed (fortunately there is only one language?). Then there is another layer, that of modeling and approximations. In the case of y=mx+b, its only a line within one model, it could be anything. Being visual beings, the most beneficial is perhaps geometric (lines, surfaces, etc). Then upon this there is the computational modeling, the numerical methods/analysis if you will.

As to how do i think of things, I like to think in the modeling perspective. That is, I like to conceptually model some process, and then apply the math and then the numerical methods. Middle out development if you will (to draw an N-tier analogy).

As an afterthought, perhaps the modeling could be called engineering.

ccook
+1  A: 

Math for a programmer is like a hammer for a carpenter. The carpenter doesn't use the hammer for everything, but if he doesn't have one, there's a lot he can't do.

iandisme
+1  A: 

Not sure what your precise question is ... Some thoughts:

  • Programming is nothing but math (Functional programming, Lambda calculus, programming == math)
  • Math is a kind of language - An abstract description/representation of an expression in thought
  • Math helps you to formalize expressions: Instead of For all integer numbers x from one to ten the square of x is less than 250 you can write ∀x ∈ {1..10} (x² < 250)
  • Programming (a programming language) does the same thing and helps to formalize algorithms.

  • The kind math that is commonly used in computer programms is numeric math, but with some efforts, you can also perform symbolic computations

Dario
A: 

The best way to get the type of understanding that you're looking for is to work through "story problems" (i.e. problems stated in words rather than equations). From this and your other questions, you're mostly looking at trigonometry.

In short, I would recommend trying the trig book from the Schaum's Outline Series -- they are cheap (~$13) and have lots of problems with solutions.

There are other routes to finding problems in math to solve, such as just make up game design problems to solve. Here are two: 1) show an object moving around a circle at constant speed, and 2) show two object moving along to different lines that don't intersect, and draw a line between them. Or you could get a book that walks you through these types of things. But you've got to work out a number of problems to force you to think things through yourself.

tom10
+1  A: 

I think math is really the concepts behind the symbols instead of the symbols themselves, but when most people speak of math, they're not making the distinction. They're just thinking of the symbols. Partly, this is because of they way math is taught in school, where the focus is on the mechanistic manipulation of the symbols to get correct results, rather than what the concepts are.

This is similar to the way non-programmers view programming. They look at a computer program and see gibberish, whereas a programmer in the given language (after more or less effort) understands the behavior the code represents.

Some people are better at retaining the meaning of such symbols than others. I think there are people who might appreciate math more than they think if they could get past that barrier to the concepts.

Anon
I agree. Thank you.
johnny
An analogy I just thought of:Math notation, after some point, is to most people (including myself more than I would like) what Brainfuck is even to most programmers, even good ones perfectly capable of understanding and creating the logic of the program if written in a language they understood or cared to decode.When I did Project Euler problems, for instance, I really had to make an effort to find explanations for math concepts I didn't know that explained them in English rather than solely in math notation. Makes me wonder if there could be a Python analog for math notation...
Anon