Software Engineering

What Maths Taught Me About Writing Better Software

Kamohelo Mntuze December 1, 2026
What Maths Taught Me About Writing Better Software

What Maths Taught Me About Writing Better Software

When I transitioned from mathematics to software engineering, I quickly realised something interesting: although I wasn't solving differential equations or proving theorems every day, I was still using many of the skills mathematics had taught me.

At first glance, mathematics and software engineering seem closely related. Both involve logic and problem-solving. But I've come to appreciate that the connection goes much deeper than knowing how to work with numbers or write equations.

Mathematics taught me a particular way of thinking. It taught me to question assumptions, break complicated problems into manageable pieces, look for patterns, and care about why something works rather than simply accepting that it does.

Over time, I've realised that these habits are just as valuable when writing software.

Here are some of the lessons that have stayed with me.

1. Understand the Problem Before Trying to Solve It

One of the first things mathematics teaches you is that understanding a problem is often more important than immediately attempting to solve it.

When faced with a mathematical problem, you begin by identifying what is given, what is unknown, and what you're trying to establish.

Software engineering should work the same way.

It's tempting to jump straight into writing code as soon as a requirement is presented. I've learned that taking time to understand the problem can save significantly more time later.

2. Break Complex Problems Into Smaller Ones

In mathematics, complicated problems often become manageable when you decompose them into simpler problems.

You might prove a theorem by coming up with several smaller results first. You might solve an equation by transforming it into a form you already understand.

The same approach applies to software engineering.

Each responsibility becomes easier to understand, implement, and test independently.

3. Always Question Your Assumptions

Mathematical reasoning depends on assumptions.

A theorem might be true under one set of conditions and false when those conditions change.

The same is true of software.

These assumptions can easily become bugs.

Thinking mathematically means making assumptions explicit and examining whether they hold.

For instance, if a function expects a non-empty list, what should happen when an empty list is passed?

Should it return a default value, raise an error, or handle the situation differently?

There isn't always one correct answer, but there should be a deliberate decision.

4. Correctness Matters More Than Something Simply Working

This is probably one of the biggest lessons I've carried from mathematics into software engineering.

In mathematics, getting the correct answer isn't always enough. You're expected to justify why your answer is correct.

Suppose someone claims that a particular mathematical statement is true for every positive integer. Checking that it works for the first ten integers doesn't prove the statement.

Software testing presents a similar challenge.

A function passing ten test cases doesn't necessarily mean it's correct for every possible input or test case.

This mathematical mindset encourages me to think beyond the happy path.

Testing is essential, but so is understanding the assumptions, boundaries, and guarantees of the code we write.

5. Simplicity Is Often a Sign of Deeper Understanding

Some of the most satisfying moments in mathematics happen when a complicated problem turns out to have an elegant solution, like the Dirac Equation in my opinion.

What initially requires pages of calculations can sometimes be reduced to a few lines once you recognise the right pattern.

I've found something similar in software engineering.

It's relatively easy to make a simple problem complicated. The real challenge is making a complicated problem understandable.

This doesn't mean writing the fewest possible lines of code. A clever one-liner isn't necessarily better than five readable lines. A software engineer who follows standard and best practices will know the basic rule of keeping your code readable.

So, simplicity means reducing unnecessary complexity while preserving correctness and clarity.

The best solution is often the one another developer can understand without needing an explanation from the person who wrote it.

6. Optimisation Starts With Understanding What Matters

Mathematics teaches us to think carefully about optimisation.

You don't optimise something without first defining what you're trying to improve and understanding the constraints.

The same principle applies to software performance.

Before optimising a piece of code, it's worth asking whether that code is actually responsible for a meaningful performance problem.

Optimising the wrong part of a system can introduce complexity without producing meaningful improvements.

This is where mathematical thinking becomes particularly useful: define the objective, identify the constraints, measure the behaviour, and then improve the solution.

Final Thoughts

Studying mathematics didn't teach me how to deploy applications, configure cloud infrastructure, or work with modern software frameworks.

I had to learn those skills separately.

What mathematics gave me was something more fundamental: a framework for approaching problems.

It taught me to question assumptions, to value clarity, and to look for simpler explanations of complicated things.

I'm still learning how to apply these lessons as a software engineer, and there are plenty of situations where I don't get everything right.

But one thing has become increasingly clear to me.

The most valuable thing mathematics taught me wasn't how to find answers. It was how to think carefully about the questions.

And that has made a difference in the way I write software.

Back to blog