Jump to content

Mathematics: a programmers best friend


Recommended Posts

This is my first revision of "Mathematics: a programmers best friend".

Mathematics is the basic foundation for everything in life, so it does go without saying that in order to excel in life you need to know maths.

A programming language, is just that: equations, put in a different format.

Take for instance linear programming, making graphs would be much more difficult if you don't know how to do it.

Throughout time, some of the greatest accomplishments were done with the use of math. Pythagoras is a one of them, the ancient Egyptians, and more modern: Einstein and Isaac Newton. All of these people made life easier for us all, by creating formulas for doing things easier and more efficiently.

That is just what programming is: making life simpler. Imagine if no one ever figured out how to program, we'd still be using our feet to walk across continents with our little stone tablet we scratched something on with another rock. But instead, we've created cars, machinery and... the Internet.

A few mathematical(or arithmetic) operators to know about, are:

+ - Addition.

- - Subtraction.

* - Multiplication.

/ - Divition.

% - Modus.

^ or pow(x) - to the power of.

Here are a few reference equations that will make your life easier when programming. (please excuse me if I'm getting this wrong, I'm only translating for Afr.)

Simple interest:

A = P(1 + i.n)

$interest = ($amount * (1 + (($interest_percent/100) * $intervals));


Compound interest:

A = P(1 + i)^n

$interest = $amount * ((1 + ($interest_percent / 100)) ^ $intervals);


Annuities (basic):

Fv = x[(1 + i)^n - 1] / i

$total = ($amount * (((1 + ($interest_percent / 100)) ^ $intervals) - 1)) / $intervals;


Those are just rent-orientated, which one could probably use for calculating financial components within a game. I will add some more as I come to think of it.

Link to comment
Share on other sites

Its not linked to game development, but If your interested in math style programming problems you may find http://projecteuler.net interesting. Even the easier problems on there really get you to think.


Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

Maths does work its way into everything, I know there were quite a few times when working on my old game that I had to really think about how it was going to work. Pen and papers still useful before programming it :)

Link to comment
Share on other sites

Thanks for providing the link, Jeff. It will really help a lot of people further their maths.

I'm just concerned that some of the youngsters(well, younger than me) will find these things a bit hard.

It always gets me when a programmer says they're not good with math, I just don't get that, and I'd hate to see their scripts. :\

Link to comment
Share on other sites

I'm just concerned that some of the youngsters(well, younger than me) will find these things a bit hard.

Having finished A levels last year I know that (at least in my area) they don't push maths at all. However History is an important A level for everyone, apparently.

Luckily I've always found math interesting and seem to be doing ok so far :) I think for programming its mainly important to have a logical and mathematical approach to problem solving, even if you don't realise that's what your doing.

Link to comment
Share on other sites

Being good at Maths will mean you will be good at anything you do. You will look at things in a different manner and your approach to problems will be much more logical and systematic, meaning you will achieve better results in anything you. I've always been pretty good at Maths and its helped me a lot :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...