MakeWebGames

# 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:

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

##### Share on other sites

Thanks a_bertrand. Any ideas for more references?

##### Share on other sites

well, math are a huge subject, but when related to games they are extremely useful and needed. So I would maybe dig a bit more and show what you can do with math... like 2D games and more.

##### 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 :)

##### 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. :\

##### Share on other sites

Well, maths isn't my forte (I disliked the subject at GCSE and below) but, i do learn maths in a fun(ner) way - through programming.

Thanks for the link Jeff and the "article" Spudinski.

##### Share on other sites

I like maths, I'm not too bad at it.. Top set in my school, predicted an A/A* Always found it enjoyable, as I can do it.

##### Share on other sites

I hardly believe that a programmer can be bad at math, or maybe he/she is picking the wrong job!

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

##### 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 :)

## Join the conversation

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×

• #### Marketplace

• Discord Chat
• PBBG Directory
×
• Create New...