DEV Community

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

Why we need MATH for Programming (10 math concepts)

Programming with Shahan on November 03, 2023

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