Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Mathematical Concepts Useful for Programming

math

  • Please log in to reply
8 replies to this topic

#1 TwelveWings

TwelveWings

    CC Lurker

  • New Member
  • Pip
  • 4 posts
  • Learning:Java, C#, Python

Posted 20 March 2015 - 11:55 AM

Being that I am interested in being a professional programmer, I know that understanding mathematics is advantageous. I, personally, enjoy math: although I do find it difficult. With that said, I am an Information Systems major. As has been my experience, my degree program does not focus much on mathematics; the only time I ever needed to use calculus was in a statistics course. This leads me to wonder, what mathematical concepts should I be aware of that are pertinent to my intended career path? (I intend to enroll in some math classes at some point--though not in the near future, considering I am a bit exhausted of academia.)

 

Also, I apologize if this was the incorrect place to post this. I was torn between Members Lounge or General Programming.


Edited by TwelveWings, 20 March 2015 - 11:55 AM.

  • 0

#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 22 March 2015 - 09:44 AM

I don't think you need Math knowledge beyond the basics for being a programmer. You do need general knowledge of mathematics as a tool to know when you need one Math concept into your program, then you can choose between deepen in that specific mater, or into translate formulas into algorithms, which is pretty much it. If you can read Math enough as for translating it to code, then you don't need the specific knowledge.

Of course if you are to program things derivative from Math, like encryption, well, the more you know the better.


  • 1

#3 gonzaw

gonzaw

    CC Newcomer

  • Member
  • PipPip
  • 15 posts
  • Programming Language:Java, C#, Haskell, Others
  • Learning:Haskell

Posted 22 March 2015 - 03:52 PM

Programming isn't just randomly putting instructions into a CPU. You "code" in a programming language, using certain constructs. You learn what these constructs are, and you believe that the resulting compiled/interpreted code will do what those constructs say.

But how can you be sure? After all, there are hundreds of programming languages who "say" they can do stuff, but you never really check the bytecode they generate by hand to figure out if they do what they say they do. 

You could just create unit tests and be done with it, but remember, testing can only prove the presence of bugs, not their absence

 

But you can do this with Math. Programming languages are, in fact, languages. This means they have a syntax and semantics. There is a lot of theory behind the semantics of programming languages, and these deal with math. 

 

 

For example, take this code from a generic programming language:

int a = 0;
int b = a + 2;
return b + 5;

Tell me, what does this piece of code return? You almost inmediately said 7, right? But how did you know? After all, those are just squiggles that get compiled into bytewords of 0s and 1s that get passed into a CPU, nobody said those are real mathematical functions. For instance, the compiler can always define "+" as substraction, so the result actually ends up being -7. Or maybe "int" is a new word for "Interesting String", and "+" is string concatenation, so the result is actually the string "025".

 

Here is where math comes in. That code above has both syntax and semantics. Syntax is basically what determines what the squiggles are. You could have "int a = 0;" or "Integer a := 0;" or "var a = 0". All of those are syntactic differences. The semantics is what is important. "int a = 0;" tells you that you have a variable with name "a", that has a type "int", which you assign to a value 0. In programming language theory, all these concepts are defined and their semantics tells you what you can do with them, and how. In this case, the type "int" tells you that any value that a variable of that type holds can be assumed to be a mathematical integer when you reason about the code. The language also has semantics for "+", which tells you that it is a function that represents the mathematical addition.

WIth this knowledge, you can safely reason about your program, and be 100% sure that the result will be the integer 7.

 

All of this was only possible because of the abstract math behind the design of the programming language that allowed you to reason about the code above. In fact, you can also apply "regular" math (e.g algebra) because of this (like we did above, by using mathematical integers and addition to figure out the result).

 

 

This is what I find fascinating about programming. It is basically the nexus between the beautiful and elegant world of mathematics, and the ugly and mechanical world of electronics. You need the former to be able to reason about things and make meaningful decisions, but you need the latter to actually do things in the real world.

It's like magic


  • 1

#4 Grigorios

Grigorios

    CC Lurker

  • New Member
  • Pip
  • 4 posts
  • Programming Language:Java, (Visual) Basic, Python, Visual Basic .NET, Assembly, Fortran
  • Learning:C#

Posted 23 March 2015 - 01:21 AM

Since your major is for Information Systems a good book to start with is from Addison Wesley "Discrete Mathematics for Computer Scientists".

Of course there are more books you need to read in case you have to work with graphics (e.g. to create 3d, perspective views etc...)

However, prior to start with any book you should decide on what kind of software you need to develop.


  • 0

#5 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 23 March 2015 - 04:35 AM

It's going to depend to a certain degree on what you plan to do, and what you've had so far. Discrete math is always useful for programmers. Abstract algebra was my key to really understanding operator overloading, classes, etc. If you want to implement implement approximations of integrals, then there are a few numerical approximations courses you can take.

 

With that said, you can sometimes do just as well with no additional math. Much of programming uses relatively little math, beyond a little bit of algebra.


  • 2

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#6 JonElias

JonElias

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 201 posts
  • Location:Trondheim, norway
  • Programming Language:Python, JavaScript, Bash
  • Learning:C++, JavaScript, Others

Posted 25 March 2015 - 01:34 PM

your signature is "Programming is a branch of mathematics"  thought


  • 0
"computers are useless they only give you answers" Pablo Picasso
And yes he was alive when the first programmable computer was made

#7 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 26 March 2015 - 04:25 AM

From a purist standpoint, it is. If you write even one line of code, you are doing math. However, most people who ask, "What math do I need to know to do programming?" are generally asking from the mindset that math is algebra/calculus type stuff. I try to answer within that understanding. Half my graduate math courses were cross-listed as CS :)


  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#8 TwelveWings

TwelveWings

    CC Lurker

  • New Member
  • Pip
  • 4 posts
  • Learning:Java, C#, Python

Posted 19 April 2015 - 12:41 AM

BlackRabbit: I see! Thank you for answering.
 
gonzaw: Fascinating, thank you for answering. Honestly, that is a goal of mine: to bridge the worlds of hardware and software, and understand both.
 
Grigorios: Thank you for the suggestion. Inundated as I am with coursework, I am a bit hesitant to delve into another textbook. Still, I will keep it in mind.
 
WingedPanther: Ideally, I would like to get into programming video games. I know it is a bit of a general goal, but I am still trying to wrap my head around all the various possibilities for programming. With that said, I would love to grasp the basic theory from which programming language is derived; so, I’ll probably still take a few math courses later on in life. At this point, I understand what the code does, but I don’t understand why. Haha. Thank you.
 
Thank you everyone for taking the time to answer—pardon my delayed responses. I was more concerned with whether or not there was some math theory that I, as an Information System, would not have been exposed to and is relevant specifically to programming.  However, some of the explanations I received have helped lessen this concern.

  • 0

#9 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 20 April 2015 - 04:41 AM

If you're going for game programming, you will probably want calculus, as the basis of physics, along with linear algebra and combinatorics. Statistics would probably be good as well.


  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download