Skip to content

Is Maths Necessary as a Programmer?

Often it’s said that programming and maths are 2 closely related fields, yet it may not be so obvious how maths comes into programming. Let me make this clear.

Maths is not completely essential to make it as a programmer

According to Simple Programmer, maths is not required, but it definitely helps you. It helps to know some basic math skills such as algebra, and discrete foundational maths as programming is heavily logical, if statements and all that, but the statement that you can’t learn programming if you can’t cut it into college maths is just not true.

Not knowing maths, it doesn’t become impossible manage different variables, compare them, iterate through them, etc. Perhaps you are subconsciously better at dealing with functional and logical operations in the program rather than abstract mathematics.

What maths does though is that it helps you recognise patterns in programming. You can look at a problem and think “Oh, I know how to solve this” because you recognise this pattern as you’ve seen before in calculus and as compared to taking 20 hours to solve that one problem, it only takes you 1 hour and you save so much time.

So I’m going to list a few examples where maths does come useful in such situations

1. Computing Spaces to Place Objects in an Interface

(I thought you would no longer use this example)

It’s my best example. Why wouldn’t I?

(…)

Maths can come quite prominently into play in both front-end and back-end. This is an example of maths in front-end programming.

Here, Class-ify creates a full-week timetable view of all of your classes. It has to take in several factors here: the size of your phone, the relative length of your classes, the times your classes start, and the duration of the full school day. It has to then perform lots of computational maths to work out the placement and sizes of each rectangle where they should be placed.

These are basic arithmetic operations, but when properly put together, they ultimate create the layout that is shown above. Being able to know what arithmetic operations to use and how simple changes in these affect what happens in the program is an essential skill in programming.

 

2. Functions

This may seem like a ridiculously simple example if you have any programming experience whatsoever, but this is just to further emphasise on how maths enables you to identify ‘patterns’ in programming.

In maths, a function is to perform an operation on a number to receive a different number, for example, y = f(x), where f(x) = x2.

In programming, it is essentially the same thing. You pass an input parameter, an operation is carried out using that variable and a value is returned, for example, b = square(a). See the similarity?

 

3. Transformations

 

This short video is taken from the Material Design Guidelines created by Google. Motion design principles are used here to make the movement of the ball look more natural as it eases in and out as it moves. To do this, certain formulae are at work  to calculate the speed that the ball moves at based on how long it’s been from when it starts moving or how close it is to its destination.

Here is another example from a more mathematical standpoint. If you’ve done any secondary maths at all, you’ll recognise this as a quadratic graph. These are often used to draw curves and circles, as well as to calculate speeds and angles that increase or decrease exponentially.

 

… And it doesn’t end there.

 

There is a wide variety of things that maths is used for in programming, going from simple to more complex operations. If you have knowledge of simple or higher level maths, that’s great! It will definitely help you be a more efficient programmer and save time along the way, although if you don’t, no need to worry. As you proceed to create more complex programs, you will naturally start integrating maths into your programs and get better at it with experience. Practice makes perfect is all.