DEV Community

Cover image for Why we need MATH for Programming (10 math concepts)
Programming with Shahan
Programming with Shahan

Posted on • Updated on

Why we need MATH for Programming (10 math concepts)

Many people believe that you don't need to know any math to be a computer programmer. While that may be partially true, understanding some essential math concepts can make programming much more accessible and help you unlock the secrets of the digital world.

Now, let's explore the 10 math concepts that every programmer should be familiar with.

10 math concepts cover image by shahan

1. Boolean Algebra

Boolean algebra is a fundamental concept in programming. It deals with binary variables that can have only two values: true or false. We use three operators to work with Boolean values: AND, OR, and NOT.

Imagine these as tools for making decisions. For example, if you want to know if someone is both rich and handsome to get a girl, Boolean variables can help you decide. If both conditions are met, he gets a girl. If not, he may have other options. You can represent this logic using if statements, Venn diagrams, or truth tables.

boolean algebra image by shahan chowdhury

2. Numeral Systems

Computers use base-2 (binary) numeral systems, unlike humans who use base-10 (decimal) systems. In base-2, numbers are represented using only two symbols: 0 and 1. Understanding binary helps us work with other numeral systems like hexadecimal (base-16) and base-64, which are essential in programming, especially for encoding and representing data.

Image by shahan chowdhury of binary base-2 vs binary base-10

3. Floating Point Numbers

Floating point numbers are how computers represent real numbers. They are not always precise, which can lead to tiny errors in calculations. These numbers use scientific notation to handle large and small values efficiently. Knowing the limitations of floating point numbers is crucial for avoiding these errors in your code.

print(1.00000000005)  # A positive float
print(-85.6701)  # A negative float
Enter fullscreen mode Exit fullscreen mode

4. Logarithmic Functions

Logarithms help us understand how some natural phenomena work. Think of a logarithm as a way to measure how many times you need to cut a log to reach a specific length. In programming, logarithmic functions are used in algorithms like binary search. These functions play a vital role in various applications, from algorithms to scientific research.

5. Set Theory

The set theory deals with collections of unique values. In programming, this concept is used extensively, especially in databases, where tables are sets of unique rows. Joining sets, finding intersections, unions, and differences are common operations in this context. Understanding set theory is important for working with databases and data manipulation.

Image by shahan chowdhury of set theory

6. Combinatorics

Combinatorics is all about counting things and combinations. Whether you're developing algorithms for news apps or designing globally distributed databases, combinatorics helps you calculate all possible combinations or permutations efficiently. It's a valuable skill in programming.

Image by shahan chowdhury of combinators

7. Graph Theory

Graph theory involves nodes (vertices) connected by edges. This concept is used to model relationships and connections. Understanding graph theory is vital for solving problems like network routing and optimizing various scenarios.
Image OF GRAPH THEORY BY SHAHAN CHOWDHURY

8. Complexity Theory (Big O Notation)

Complexity theory helps you analyze the efficiency of algorithms. Big O notation is a tool for expressing the time and memory complexity of algorithms. It helps you choose the most efficient solution for your programming tasks, a valuable skill for interviews and writing efficient code.

Image OF BIG O NOTATION BY SHAHAN CHOWDHURY

9. Statistics

Statistics is essential for various fields of programming, especially in artificial intelligence and machine learning. Understanding basic statistical concepts like mean, median, mode, and standard deviation is what makes you best at making predictions. It's the foundation for making predictions and decisions in data-driven applications.

Image OF STATISTICS BY SHAHAN CHOWDHURY

10. Linear Algebra

Linear algebra is essential in computer graphics, deep neural networks, and many other areas of programming. It involves scalars, vectors, and matrices to represent and manipulate data. If you want to work with 3D graphics, cryptography, and machine learning, then Linear Algebra come into play. You need to master Linear Algebra to tackle these.

Uploading OF linear algebra BY SHAHAN CHOWHDURY

🤖 Recommendation: Use Notion to boost productivity

Notion is a fantastic tool for developers! It supports syntax highlighting for over 60 programming languages. If your day-to-day involves reading coding docs, watching programming tutorials and tracking progress, taking notes, and writing content, Notion can make you more efficient.

Notion is more than just a note-taking app. As a developer, you can use Notion to track your freelance projects, organize your code snippets, collaborate with clients, keep track of jobs you're applying for, and integrate with third-party tools to boost your entire developer workflow 10x faster.

notion for devs

Notion AI has the capacity to generate code, equations, graphs, and even explanations for code snippets. It is the smartest AI assistant that helps you think bigger, work faster, and augment your creativity, right inside the functional notion workspace you're already familiar with.

notion features

It is available as an add-on to Notion plans, including Free Plans, for $10 per member, per month. This gives you access to all AI features in Notion. A 20% discount is available to all workspaces on any plan with annual billing.

notion ai upgrade


Conclusion

Mathematics is a powerful tool in the world of programming, and these 10 concepts are just the beginning. They can help you develop more efficient code, solve complex problems, and unveil the magic behind the digital world. These math concepts will make you a better programmer, and you'll be well-equipped to conquer a wide range of challenges in the ever-evolving field of technology.

You can watch a short video of this article here:

Related articles:
The Roadmap to Frontend Developer in 6 months

Stay tuned for more valuable content, and if you find it helpful, you may also like my YouTube channel.

You can follow me on X for latest tech updates.

Top comments (16)

Collapse
 
efpage profile image
Eckehard • Edited

Even if you have some knowlede about mathematical concepts, you will find that the implementation in a certain language often differs from the generalized concept:

  • You know, what a floating point number is, but the implementation limits this to a certain number range.
  • Numerical results have a limited accuracy giving you unexpected results: 14900*(10.8/100) = 1609.200000000003 (Javascript)
  • Boolean knows True and False, but you can also write if (a > "0") ... The result will mainly depend on the language you use

So, even if you know the mathematical concept, this might not be enough to master a programming language.

On the other hand, there are some specialized mathematical concepts that are most useful to know for programmers. But they apply mainly to programming problems, so we call them computational mathematics. Did you ever hear of Homogeneous coordinates?
math

If you are dealing with 3D-geometry and need to show some perspective projection, they are very efficient to calculate the image. But the best thing about Homogeneous coordinates is that they are able to accumulate a number of transformations in a single matrix. Usually your would apply a number of transformations one by one to show an object: Assume, A, B and C are matrices that apply a single tranformation to a point P, which is a vector. If you want to calculate the projected positions, you need to write:



  P'  = P x A x B X C


Enter fullscreen mode Exit fullscreen mode

Instead, with homogenuous coordinates you write:



  H = A x B X C
  P'  = P x H


Enter fullscreen mode Exit fullscreen mode

Assume, there is not a single point, but millions of points to show. Instead of applying multiple vector multiplications, you just need to do one.

Mathematical concepts can be most helpful to programmers, but programming has it´s own rules. A good mathematician will not necessarily be a good programmer. And there are many mathematical disciplines, that apply mainly to solving programming problems. Computer geometry is one of them, discrete mathematics another one. Many programmers will not do much more mathematics than adding 1+1, but on certain fields it is good to know the mathematical concepts.

Collapse
 
artydev profile image
artydev

Eckehard, you will Always surprise me:-)

Collapse
 
shahancd profile image
Shahan Chowdhury

Wow! That’s a brilliant explanation. Exactly what I believe. Thanks for sharing this.

Collapse
 
vanessatelles profile image
Vanessa Telles

I agree that it's essential to have a solid grasp of the fundamentals and progressively deepen the knowledge as the need arises.

But when it comes to game development, the requirements often extend beyond the basics and may even demand an understanding of physics.

I'm not trying to discourage anyone, but it's good to be aware of this if you're interested in pursuing this career 😅

Collapse
 
codewithshahan profile image
Programming with Shahan

Yep! I agree with that.

Collapse
 
yxm profile image
Yuri Ximenes Martins

Hi. Thanks for your post. I totally agree that math is fundamental for being a nice programmer. Actually, I could added some topics to your list that are important to understand what programming really is.

  1. Formal systems: programming languages are particular examples of formal systems. Studying formal systems allow you to think about programming in a more formal way.
  2. Type Theory: any programming language that has data structures is a kind of type system. Studying type theory allow you to better understand what is the role that data structures play in a programming language.
  3. Category Theory: the topic above are about the syntax of programming languages. Category theory, on tge other hand, plays a fundamental role in the description of their semantics.
Collapse
 
slobodan4nista profile image
Slobi

I like this kind of articles, right on the points.
"Intuition" math is what most coders need, but in order to solve any complex problem math probably already has a solution that you only need to employ. Learn as you go and don't fear math it is 🌻

Collapse
 
codewithshahan profile image
Programming with Shahan

Exactly! Don't fear math. Learn when needed. This is how you can master programming as you go along.

Collapse
 
erfanasadi profile image
Erfan Asadi

Very Useful for **me **and my followers!

Collapse
 
codewithshahan profile image
Programming with Shahan

GREAT!!

Collapse
 
jmuney profile image
jasaan

Man I’ve been to interested in cryptography and learning algorithms and python man , I would really like to tap in with someone hands on

Collapse
 
codewithshahan profile image
Programming with Shahan

Hey jasaan, Thanks for sharing your interest. I would recommend you start with a programming language (python is most popular for beginners), then learn algorithms, cryptography and so on. You can always ask me questions on LinkedIn or Twitter.

Collapse
 
danbailey profile image
Dan Bailey

I mean, other than that incel garbage in the first diagram, this was a pretty solid article.

Collapse
 
anitaolsen profile image
Anita Olsen • Edited

I have understood that basic math is what is needed for most programmers. For game programmers on the other hand, is knowledge of Vector Math in addition to basic math, important (which you already mentioned in 10. Linear Algebra).

Collapse
 
codewithshahan profile image
Programming with Shahan

Yes, it's true that basic math is enough for most programmers (e.g. web developers), as they usually don't need to be involved in complex tasks such as game development, competitive programming, and so on. But knowing them is super beneficial to sharpening your coding skills.

Again, I believe learning things when necessary is the best way to master programming. Learning lots of things without applying them is never going to be helpful. This is what I experienced after spending countless hours learning useless things that I didn't need. I rarely remember lots of programming concepts that I haven't used in the past few months.

Collapse
 
allexwang profile image
zhigang

You can take a look at AI-related analysis at bestaiproductlist.com/