Jump to content

Check out our Community Blogs

- - - - -

Why Mathematics Is Important To Programming

Posted by DarkLordCthulhu, 08 June 2012 · 3126 views

I am of the opinion that the better you are at math, the better you are at programming. The value of mathematical knowledge in this area is something that is overlooked and underappreciated by many people in the tech industry, and this is probably part of the reason we have so much $hitty software that either runs slowly, is unintuitive, or has some other problem. In an effort to appeal to as many developers as possible, organizations like Microsoft, Apple, and various open source projects have been dumbing down programming languages so they require as little skill as possible, and when programming requires only a minimal level of skill, people often only learn a minimal level of skill. That's just my opinion; feel free to disagree with it.

In this blog entry I plan to go over some of the reasons mathematical skill and knowledge is important, and some of the areas of mathematics that are applied to computer science and programming. There are several ways to justify investing in a mathematical education. For example…

1. Mathematics teaches you to think logically. Most programming languages do not use a simple, English-like syntax. There are a few exceptions to this rule (Python, SQL, Applescript, and a few others), but usually programs have a rigid structure and making them work requires analytical, rather than intuitive, thought.

2. You learn problem solving skills. This is actually the main reason mathematics is taught in high school. Most students will never need to figure out geometric constructions or differentiate functions at any point in their lives, and most will simply forget what they've learned, but the effect that a mathematical education has on the developing brain helps with finding solutions to everyday problems. The same is true of programming.

3. Certain areas of mathematics are directly applicable. This is not readily obvious if your entire education consists of writing tic-tac-toe programs and simple Windows utilities. For anything advanced, a knowledge of both pure mathematics and abstract computer science is not only helpful, but also necessary.

Here are some of the branches of mathematics and how they are applied:

Set theory: Set theory is the basis for the rest of mathematics, and also for several areas of computer science. The theory of computation focuses largely on sets and on determining membership within sets. Database theory is also based on set theory, and tables are analogous to relations.

Formal logic: Logical calculi form the basis for several areas relevant to programming. Logic programming languages like Prolog are derived from the predicate calculus. The lambda calculus, another logical calculus, serves as the basis for the functional paradigm. And of course there's Boolean logic, which is directly applied throughout programming as well as in computer architecture.

Number theory: Properties of numbers are used heavily in cryptography and the theory of computation. The RSA protocol uses Euler's function to encode data. Formulae in a formal language are encoded into Gödel numbers for computation, a process that relies on the fundamental theorem of arithmetic. Encoding of numbers in binary, octal, and hexadecimal relies on the basis representation theorem.

Graph theory: Binary trees, linked lists, parallel architectures, and computer networks are best represented by graphs, and there is a branch of mathematics devoted to the study of general properties of graphs that can be applied to these structures.

Linear algebra: Linear algebra has wide applications in many areas of computer science and programming, including coding theory, transformations in computer graphics, and solving optimization problems, among other things. It also has applications in other branches of mathematics that may be applied to programming.

Calculus: Calculus is crucial for understanding physics, and physics allows a programmer to achieve accuracy in things like 3D gaming and simulations.

Vector analysis: Vectors are used in many forms of graphics and animation, so much that SIMD architectures are designed with vector calculations in mind. Also, like calculus, vectors are applied heavily in physics.

Automata and formal languages: Automata and formal languages are used in parsing and the design of compilers and programming languages. Regular expression parsers can be built with finite automata, and the Backus-Naur form is basically a condensed form of a context-free grammar. Also, a Turing machine is a type of automaton.

Those are just some of them. There are probably more.

  • 1

Hey DarkLordofthePenguins,

I agree with you that the knowledge of mathematics is extremely important and valuable for a programmer or just a casual person interested in programming. However, one should not overestimate one's power. Let me explain.

I am a senior Econ major. During my academic career I have taken some math courses (3 semesters of Calculus, Linear algebra, and Statistics); however, taking some upper level courses that you've mentioned (like graph theory), would be hard for me. In other words, there is a point in every student's life when he achieves a ceiling of mathematics. Speaking in econ terms, I started getting diminishing returns when I "shopped" for Number Theory (I dropped out before the grade penalty kicked in). The level of abstract thinking was just too high for me. Of course, my case provides anecdotal evidence.

However, it is reasonable to **ume that math majors also reach a certain level where the abstract thinking is well too abstract :)
I am not sure about Comp sci majors though. Some of my acquaintances from the Comp Sci department have the same math background like me, but with the comp sci load.

Truth be told, I rather regret for not concentrating on math earlier :(
    • 0
I must agree with DarkLordofthePenguins , but I am one of those who are against philosophy that programming is all about math knowledge. It is ok to know math so you can work with graphical applications or to create them. It is ok to know some statistic math like combinatorics so you can calculate the speed of specific algorithm. But when I program some application, my code is using only 1/20 lines of the code for math statements.
    • 0
I completely agree! I think math is much more important than people realize, and I also love math. That's why I'm earning a double major in Math and Comp Info Science :)
    • 0