Does algebra benefit programming?

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 4698 Views - Last Post: 04 July 2015 - 03:28 PM

#1 Shadow-coder   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 59
  • Joined: 04-June 15

Does algebra benefit programming?

Posted 28 June 2015 - 08:51 AM

I apologize if this is in the wrong forum, please move it if it is.

I was just wondering if practicing algebra has any positive effect on programming skills, or just any effect on programming at all.

I've been out of school for about a year and a half now (19 in a few months) and I've forgotten half the stuff i learnt in school with regards to algebra, i did enjoy the subject though and would love to, i guess "Re-learn" it so I'm just wondering if it has any effect on programming per say.

Also if you have any good resources on algebra "Re-learning" I'd very much appreciate the links.

Thank you for your replies

P.S I'm really enjoying this site :D/>

This post has been edited by Shadow-coder: 28 June 2015 - 08:52 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Does algebra benefit programming?

#2 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

Re: Does algebra benefit programming?

Posted 28 June 2015 - 08:54 AM

Moving to Student Campus.

Any algebra used in most aspects of programming is quite basic, not pushing Algebra I. If you're doing high level work (such as cryptography), then Number Theory and Abstract Algebra become important. I don't think you're asking about Abstract Algebra though. :)

We have a lot of folks ask about math and programming. I'd advocate poking through some old threads listed in the Student Campus FAQs.
Was This Post Helpful? 2
  • +
  • -

#3 Shadow-coder   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 59
  • Joined: 04-June 15

Re: Does algebra benefit programming?

Posted 28 June 2015 - 08:59 AM

Thanks for the information, i'll go poke around in the student campus then. :)

Do you think it's beneficial though?

I wish back when i was in school i knew what i wanted to do haha, if i knew i wanted to do programming back then i would've made my journey towards becoming a programmer much easier or atleast a little bit <.<
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

Re: Does algebra benefit programming?

Posted 28 June 2015 - 09:03 AM

More math is always better than less. The high school algebra is mostly about tools you'll need. The stuff that trains your brain in the way you'll want as a programmer is the discrete math content- number theory, combinatorics, graph theory, set theory, logic, etc. You need the high school algebra tools to talk about discrete math topics.

So it depends how much you want to train your brain on these kinds of things. Many folks benefit from it. Conversely, there are folks who don't like math and do just fine at their jobs programming.
Was This Post Helpful? 1
  • +
  • -

#5 Shadow-coder   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 59
  • Joined: 04-June 15

Re: Does algebra benefit programming?

Posted 28 June 2015 - 09:12 AM

Okay, i'll keep that in mind, i would love to be the best programmer i can be i just need to stay motivated and not doubt myself (i have a tendency of doing that).

Thank you for your help, i'm glad i joined this site, you have some very helpful people here and alot of good information. :)
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

Re: Does algebra benefit programming?

Posted 28 June 2015 - 09:17 AM

Glad I could help! :)
Was This Post Helpful? 0
  • +
  • -

#7 BBeck   User is offline

  • Here to help.
  • member icon


Reputation: 792
  • View blog
  • Posts: 1,886
  • Joined: 24-April 12

Re: Does algebra benefit programming?

Posted 28 June 2015 - 09:50 AM

I've always heard that computer programming involves a lot of math. I've been programming since I was 12 and have yet to figure out what they are talking about.

What little bit of math I've seen over the years in business programming and what not has been rudimentary algebra such as A=B/(C+11) and such. Since I was 12, the math has not gotten much more intense than that.

But there are specialized applications where the math can be an enormous part of it. Obviously, if you are writing engineering apps that do engineering calculations, that's going to involve a lot of higher level math.

And then there's game programming. Game programming is where the saying finally became true. There can be a lot of math in game programming. I would say algebra is prerequisite. Not that you are going to use a lot of algebra, but the trigonometry you will be doing requires a solid understanding of things like the associative and distributive properties. You don't need to be able to quote the rules, but you do need to understand how one formula became another.

For example, I'm working on putting together a tutorial on how to write a Blinn-Phong shader in HLSL for game programming. And in the tutorial I'm walking through the proof.

The code is:
ReflectedLightDirection = 2.0f * PixelNormal * saturate(dot(PixelNormal, LightDirection)) - LightDirection;

And in a more standard math equation that is:
r = 2n(n dot l) - l

where all of those variables are actually 3D vectors rather than just singular values. (Vectors are covered in Trig along with the vector dot product).

So, in my tutorial, I have to explain why this is true.

If I get the video finished soon I'll link it. It's a somewhat long proof to explain. But it starts out with this:
n(cos theta) - l = s

and

r - n(cos theta) = s

Here's where the algebra comes in because if you know algebra, you know you can set the two equations equal to one another and get

n(cos theta) - l = r - n(cos theta)

And with algebra, you can also rewrite that as:

2n(cos theta) - l = r

It's a given that cos theta = n dot l (the dot product of n and l). So with algebra you can rewrite it as:
r = 2n(n dot l) - l


So, this is really a vector problem that is basically some fairly advanced trigonometry or some linear algebra. It's not really an algebra problem; we're just trying to figure out how the equation works. But to really understand the steps needed to get from the starting point to the ending point, you need to be fairly solid in algebra.

Trigonometry is probably the primary math for game programming and it is very heavily used. The algebra is only rarely used except that when you are rewriting or trying to understand the trig equations, there's a fair amount of algebra involved. And in 3D game programming and graphics there is quite a bit of vector and matrix math, which is linear algebra, although what we use is just a small subset of the subject.

You're probably only doing math like this maybe 5% of the time in game programming. But when you do use it, you need to understand it.

But again, we're not really using the algebra directly pretty much at all. Its use is almost entirely for understanding what the trig equations are doing because they are a combination of trig and algebra.

And I've never had anything remotely this mathematical working in IT pretty much my entire adult life. At work, it's all A=C+B and that's about as complicated as it gets.
Was This Post Helpful? 3
  • +
  • -

#8 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11986
  • View blog
  • Posts: 20,312
  • Joined: 19-March 11

Re: Does algebra benefit programming?

Posted 28 June 2015 - 12:30 PM

It's true that I very seldom do more than trivial calculations in my work as a programmer - generally it'll be limited to figuring out how much of a given resource I need for a given process, or working out placements of objects in a layout, basic arithmetic. Once in a while I've found it useful to do something a little more complicated, but that's pretty rare, and the applications were, admittedly, pretty optional. (ie, establishing that something that was obvious was also true)
However, there are two other considerations. First, software engineering (ie, "programming") is the use of entities defined in computer science, and to use those entities well, it is necessary to understand them. One very good way to understand them - the only way to really understand them at all - is to learn the computer science that underlies them. Computer science is math, these definitions are mathematical in nature, so in this sense it's impossible to really program well unless you do at least some math. As mac says, the stuff you need for this is largely covered in discrete math, although some calculus is extremely helpful. (the holes in my understanding of computer science correspond to a large degree to holes in my understanding of calculus)

But there's a more fundamental issue: I don't think that math is limited to simply performing computations. Math is, broadly speaking, concrete reasoning about rigidly defined abstract entities and the operations on those entities. And if you think about it, this is exactly what programming is. Therefore, I claim (as I've done before) that programming doesn't necessarily use math, but it always is math. When you write a program, you are doing math, and you're exercising the same skills that you use to reason about sets or distribution of prime numbers or the order of a group.
This implies that the more you practice mathematical reasoning, the better you'll be at programming, quite independent of any particular benefits you get from learning CS primitives.

I would also add that while algebra is at best satisfying, real math is generally a lot of fun. There's something really profoundly delightful about wrestling with some of the problems that are lying around out there. For example, the standard proof of the irrationality of sqrt(2) feels like a great magic trick to me, and the Collatz conjecture is a deep well of insights. So there's a great pleasure to be had in doing math for its own sake.

And of course, every programming interview I've ever seen has involved a technical interview, and that almost always probes your understanding of basic CS, so you'll probably want to get those basics if you mean to get employed by someone else as a programmer.

Quote

I've been out of school for about a year and a half now (19 in a few months) and I've forgotten half the stuff i learnt in school with regards to algebra, i did enjoy the subject though and would love to, i guess "Re-learn" it so I'm just wondering if it has any effect on programming per say.


I would suggest that, rather than revisiting that material, you might want to point yourself towards areas that would exercise it. For example, you might want to take a look at projecteuler.net and see what you can make of some of those problems. Many of them will become easier if you apply a few of the tricks that you learned in algebra to simplify or rearrange the problem, so you'll probably find that a lot of what you think you've forgotten will come back to you - and you'll start to get a pretty good idea of what you really need to relearn.
(note that those problems start out pretty easy, but they quickly get into the "rather difficult" range, so don't be discouraged if you find you're stumped)
Was This Post Helpful? 4
  • +
  • -

#9 Lemur   User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1453
  • View blog
  • Posts: 3,633
  • Joined: 28-November 09

Re: Does algebra benefit programming?

Posted 28 June 2015 - 04:10 PM

*
POPULAR

Probably the most relevant maths to me are Category Theory, Abstract Algebra, Linear Algebra, and a lot of Statistics.

Category Theory

If you're anywhere around Haskell, Scala, or other statically typed functional languages you're going to want at least a rudimentary understanding here. It falls under abstract algebra and is where you're going to get most of your terms like Functor, Monoid, and Monad.

Linear Algebra

Matrix transformations and a lot of functional application comes about here. Definitely handy to have down especially if you have anything to do with image or video transformations.

Statistics

I'm a few rungs out from being called a Data Scientist of sorts. Being able to process petabytes of data at a time is one thing, being able to glean actually useful information from it beyond trivial observations? You're going to want to know a lot of statistics there, especially in the machine learning vein.
Was This Post Helpful? 5
  • +
  • -

#10 tarmizi_adam2005   User is offline

  • جوروترا

Reputation: 287
  • View blog
  • Posts: 986
  • Joined: 18-April 09

Re: Does algebra benefit programming?

Posted 29 June 2015 - 08:14 PM

As i am working in signal processing and some machine learning, knowledge of linear algebra is very important and beneficial. Heavy use of vectors and matrices are often needed. Also, solving things related to signals, are mostly modeled as systems of linear equations. So, when applying these signal processing algorithms in a programming language, a knowledge of linear algebra, vectors and matrices are somewhat important to know.

However, depending on what field you are in, it depends. Usually, a very good/detailed knowledge of mathematics are needed when you are working on engineering related programs.
Was This Post Helpful? 2
  • +
  • -

#11 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

Re: Does algebra benefit programming?

Posted 29 June 2015 - 08:57 PM

View Posttarmizi_adam2005, on 29 June 2015 - 11:14 PM, said:

As i am working in signal processing and some machine learning,

Tutorials in those areas would make excellent additions to our Computer Science tutorials section. I would certainly be interested in reading them! :)

@Lemur: You're one of now three people I know who have mentioned Category Theory. ishkabible mentioned it, but he does a lot of work in theoretical logic. My mentor from last summer does a lot of work in algebra (albeit more applied in graph dynamical systems), but he mentioned category theory as well.

Also, you're the second person to mention monoids. The other person was again, an old professor of mine when I took theory of computation. They come up quite a bit in automata theory. The set of regular languages over an alphabet forms a monoid, with the operation of set union.
Was This Post Helpful? 0
  • +
  • -

#12 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11986
  • View blog
  • Posts: 20,312
  • Joined: 19-March 11

Re: Does algebra benefit programming?

Posted 29 June 2015 - 09:20 PM

Mac - when I ran into my buddy Steve at the coffee shop this weekend, he saw me working through some of the algebra material and went straight to category theory.

Sounds pretty hip, but I think I'm not there yet. My little brain is working hard enough just getting hold of the basic structures.
Was This Post Helpful? 0
  • +
  • -

#13 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

Re: Does algebra benefit programming?

Posted 29 June 2015 - 09:24 PM

I'm not familiar with category theory, if that's any consolation. :P

My mentor from last summer was explaining that category theory looks at a branch of mathematics and helps us determine which questions to ask. I look at logic as the foundations of mathematics, or the frame of the car; and category theory as the steering wheel.
Was This Post Helpful? 0
  • +
  • -

#14 ishkabible   User is offline

  • spelling expret
  • member icon





Reputation: 1747
  • View blog
  • Posts: 5,898
  • Joined: 03-August 09

Re: Does algebra benefit programming?

Posted 30 June 2015 - 10:19 AM

On the general topic:
I claim math is not super helpful with regards to *programming* a typical application but is super helpful in regards to *computer science*

I work in a niche area and do things with mathematical logic. Most people don't do this but IMO it is the area that is the most fun. I'd say most research in computer science falls into one of 4 categories. Formal Methods/Programming Languages and related things, Machine learning AI and related topics, Cryptography/Cybersecurity and related topics, the vaguely named "theory" topics related to computation, complexity, and algorithms.

The formal methods and programming languages areas are riddled with mathematical logic and a lot of proofs. Numbers seldom come up but equational reasoning, set theory, and other formal mathematics come up all the time.
Machine learning and AI are riddled with all sorts of traditional classic math like numerical methods, calculus, probability and statistics; what people traditionally think of as math is the kind of math that is really important here.
Cryptography as has been mentioned is very number theoretic and algebra heavy (note as Mac said, I mean abstract algebra. most mathematicians just call it algebra however because context at that level makes it clear).
The "theory" topics have so much stuff in it but I can definitely say that mathematics plays a part. Big-Oh notation if understood properly is actually a set of functions from real numbers to real numbers and all sorts of calculus (limits) and math goes into thinking about it.

On category theory:
This gets used by people at the highest level of research for theory related topics. The big thing I have learned to do with it is categorical semantics where you can basically give a semantics based on category theory to sequent logics (I'm currently trying to wrap my head around monoidal categories providing semantics for linear logics). Category theory is a lot more general than that though. I'm slowly coming to the understanding that category theory lets you solve all the same problems that set theory does (if not more) but though a different lens. The key word here is "behavioral analysis". Set theory lets you describe "what do things look like and what structure do they have". Category theory lets you ask "how do things behave and interact with each other". It turns out each can in many sense subsume the other (category theory doesn't have a strict definition while set theory has many, ZFC being the most popular).

I'm gonna see if I can think up a category theory related challenge for my second challenge in the computer science fourms.

Also in regards to understanding category theory: I'm far from being able to say I understand it but definition wise I'm not sure it is actually too much more complicated than something like a ring. In fact universal algebra studies frameworks in which groups and rings and fields can exist. It turns out that it is possible to understand category theory though the lens of universal algebra. Category theory is a lot richer than any specific kind of algebraic structure however.

edit: by the way monoidal categories deal with monoids.

This post has been edited by ishkabible: 30 June 2015 - 10:25 AM

Was This Post Helpful? 0
  • +
  • -

#15 Lemur   User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1453
  • View blog
  • Posts: 3,633
  • Joined: 28-November 09

Re: Does algebra benefit programming?

Posted 30 June 2015 - 10:45 PM

If anyone's keen on Category Theory on a practical note I can write up on it. I tend to use a fair amount in my day to day with Spark jobs and Scalaz (yes, that's spelled correctly)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2