Programming, Education, Computer Science

It’s the catchphrase that many students hate seeing on the course description for their introductory Computer Science course: *“Recommended for strong math students only.”* That one single line is the source of many headaches for countless young students expressing an interest in computer science, but not necessary math. There are many questions about the relevance of mathematics to their programming courses.

Today, I hope to show you just exactly what is so important about math to high school students in their computer science class. A common scenario is **interest in video games**, but with **lack of strong math skills**. For that reason, I am going to discuss game development in this post, but be on the lookout for a future, second part to this.

Thinking at a high school level, a basic game really doesn’t involve all that much math. That’s all well and good, but when you think about higher difficulty games, there is usually a lot more math involved. In fact, let’s look at a simple side-scrolling Mario clone. In this list, we’re just listing mathematical components to a single mechanic of the game — jumping onto an enemy:

- Acceleration/deceleration for running
- Jumping/Falling
- Collision Detection
- Scorekeeping

That may not seem like much, however, after a while the task can seem quite daunting and becomes a very involved project. This list will mean you will have to keep track of your player’s velocity, and his acceleration (positive, negative, or zero) both horizontally and vertically. While you’re doing that, you’ll also have to keep track of your coordinate system to check on your player positions and if they’re colliding or not. To cap it all off, most sidescrollers usually incorporate some sort of scoring system with an exponential function representing growth for consecutive hits. While each thing is small within itself, combined, these can pile up quickly.

Now let’s move into 3D. Adding a third dimension to your game ups the ante exponentially. You have to account for a focal point, which vertices should be showing, shading and lighting, texturing, etc. All of this is math. It goes back to your simple transformations to a function on a graph, except applied to a 3D model instead. Also, when you get into rotation, you have to know how to multiply matrices, otherwise, it’s quite impossible to get a nice smooth looking animation, that still looks proper.

While I haven’t covered computer science per se, but I have hopefully shed some light on why math is important for the applications that many high school students choose to write — *games*. As a last note, if you only take one thing out of reading this article, think about things this way: if you really want to be involved with game development through coding, whether it be the actual game engine, or physics engine, etc. don’t look at the math aspect as a reason to give up, but rather, a *challenge*. Don’t be afraid to get something wrong and have to try until you get it right. It’s much better off to get something right on the 5th try by re-analyzing the problem, than getting it right the 1st try by sheer dumb luck.

Not to let Clayton discourage anyone out of the field, it should be pointed out that the complicated math doesn’t kick in until the more advanced topics of Computer

Science. Programming, as an application of the science, comes with enough drop-in engines and libraries to take all of the complexity out. Though that obviously comes at the expense of innovation.Reply to comment

Even the simple math is harder for me, since I am only in grade 8 and haven’t learned things about that stuff for making even simple games. It does help a lot if you know what you are doing for the math part of a game though. Although, trying different things (for the math part of a game) does help me get a bit better at math IMO.

Reply to comment

When I studied maths in a lot of high school, I found it difficult to focus because I had nothing to relate it to – it seemed completely abstract. I’m now studying a games programming degree which involves a lot of maths classes, but I cope fine because I can relate it to something practical. Maths seems to be an area where far more people struggle (compared to programming) though.

@michealp – I implement some of what we’re taught (out with the context of games) to make sure I fully understand it, seems to work far better than answering hundreds of questions for me.

Reply to comment

I’d also like to point out that I wasn’t trying to discourage “weaker” math students by scaring them with this information. What I was trying to do was inform everyone of why it is recommended that you be a strong math student to begin with.

@michaelp: That’s the idea, try, try again until you get it right. Like I said in my post, getting something wrong is of no consequence, as long as you have learned from that mistake and have corrected it. It’s an awesome learning experience.

Reply to comment

Hazel brings up a very good point. While high school math was trivial, I found University level calculus to be abstract enough to not be able to related to anything. Thus I’ve struggled through those classes. So now I try to apply things I learn to things I do — not just math, but philosophy, economics, law, etc. Sometimes simply talking about a subject with a classmate reenforces the understanding quite well.

Reply to comment

I attended college for a year for a computer science degree. I didn’t finish, however, in my efforts I did come to learn that programming requires a very good understanding of math principles. I can understand why it course schedules say that programming is for “higher level math students.” However, this doesn’t mean that “lower level math students” won’t be able to do study in this course…they just may have to work a little harder.

Reply to comment

Another thing that I’ve heard is “you don’t really need to know that much math for programming. The computer does it all for you.” That’s probably true for most 2d maths, but for 3D, you would need to know math.

You also need to look at things logically. For example, most collision is just “if x and x collide, if y and y collide.”

Reply to comment

@michaelp: I find math in Computer Science tends to lean more towards the theoretical side of things, rather than practical. As you said, “The computer does it all for you.” However, that is only half true, sure it does all of the calculations, but it doesn’t come up with the algorithms and structures to follow for you (ignoring any pre-written library shenanigans).

Reply to comment

Indeed, there needs to be a distinction between

Math for ProgrammingandMath for Computer Science. In programming, most math can be abstracted through libraries and engines — it’s nice to know how things work, but ultimately the details of implementation are hidden away. In science, math is required for design and formal proofs. There’s a lot of theory that is modeled by math.I think a big problem in understanding is the fact that high schools tend to teach mostly Programming, while calling it Computer Science. Programming is the application of Computer Science, and the latter could be studied as pure theory, without the use of computers. In such a scenario, the usage of Math is paramount.

Of course schools, both high schools and Universities, tend to combine both practical programming and theoretical computer science parts, as it’s difficult to learn one, without the other.

Reply to comment

[...] a computer science student, Tony Targonski, tells you the importance of math in computer science courses, of knowing a subject outside of [...]

Nonsense… I graduated with a degree in computer science and I am horrible at math. I only struggled through the Calculus courses and not my Core Courses. If you want to be a programmer you do NOT necessarily need to know how to prove any math functions. You need to know the formulas which you can find in any book. Using your resources is the key.

Reply to comment

I agree with the idea of math being a challenge. That’s how I like to look at it. I re-took my grade 12 calculus and uped my mark by 20%. The only thing I am worried about in university, is passing my math exams. I love math. Though I am terrible at it.

I remember for the first time in grade 11 trig, when I first started to see a connection. I saw the unit circle, and leant how to use it. It was then that I understood how sin, cos, and tan worked. That was probably the first time I really started to like math, because once you understand everything, you can really start doing some impressive things. With cartesian vectors, I then understood how projectiles work in 2D using sin and cos. So I also agree with relating math to things you know.

The problem is that I can’t take 2 or 3 tries to get it right. On an exam, that just doesn’t cut it. That’s why my marks aren’t that great, because I don’t get it right the first try. With a computer program, you’re allowed to run it, find bugs and fix it. But with math, the answer is unknown, and that’s where the trouble is.

My teacher told me about a saying, it’s impossible to write 1000 lines of code without a mistake, so don’t even bother trying [or something like that]. Math on the other hand, you must get the answer right to pass the course.

Reply to comment

Right now I’m in my third year of studying Computer Science, and I can tell you it’s no easy ride, that’s for certain. However, I think many universities tend to exaggerate the Math requirement on Computer Science. The reason for this is probably because they want to attract all these mathematical master minds, all of whom might possibly design the computer algorithms of the future. The design of better algorithms is an area of computer science requiring brilliant math skills, but it’s not the only area of Computer Science, and not one you necessarily need to study.

The areas of Computer Science I’m interested in would have to be software engineering, and purely as a hobby, 3D coding in OpenGL. I took Maths in High School, and I was never really good at it. I can’t say I was terrible at it either, but I wasn’t gifted with a great intellect, so in order to do well at it I had to work hard.

I shied away from doing advanced math in High School though, because I just didn’t really like it enough. Many people don’t like math, because learning the subject itself is a bore. When I started doing Compsci in University however, I did wish that I had done more Calculus in school, because it would’ve at least given me a jumpstart. However, just because you may not be good at math I wouldn’t discourage you from doing a major in CompSci.

As many have already mentioned, the amount of math required in most programming is very trivial, if not requiring any math whatsoever, at least in some areas of the software engineering department anyway. You will however need at least a general university/college background in calculus to do basic stg III courses in 3D coding and design, as you will mostly work with vectors and matrices. The more theoretical areas of Computer Science like algorithm design will require good discrete math skills though, and is not recommended if you don’t really like math as a subject, rather than as a helpful tool. Also, if you’re not too good in math, I wouldn’t recommend the low-level hardware side of computer tech either, because some of that requires a high degree of physics.

Still, you can make many choices over what’s on offer in your CompSci degree, and depending on where you’re studying, you don’t really have to go near any of the courses that demand a high level of maths. You will likely have to fill in the gaps though, and this will involve making choices you may not necessarily like, and yes, it will involve math. So if you do intend to study CompSci then I’m afraid you will have to be willing to at least slog it out in a general first year calculus course. When I started Uni I took a preparatory calculus course, thereafter I took the general calculus course, which was the minimum requirement for my higher level CompSci courses. As I mentioned, I have never really liked math, in fact I hated it as a child, but when applying it to Computer Science, especially to 3D graphics, I find that it is actually very interesting and rewarding.

I hope that I have given some encouragement to those willing to study Computer Science, but feel disadvantaged due to their math. Here’s what I suggest: study math all the way in high school. If you’re like me and didn’t go all the way with math during that time, or didn’t do too well, do preparatory courses in your first year of undergraduate study. You might still be able to finish the degree within 3 years by doing this. You should have an average grasp of high school algebra at least, though.

Lastly, don’t be too afraid of calculus if you feel your math isn’t up to scratch. General calculus is not really too hard to grasp if you work hard at it.

Reply to comment

I returned to school at mid-life to take computer courses, so my math was a bit rusty. I found that taking game courses inspired me to learn more math, even math that wasn’t yet invented back when I was a student the first time around. Back then, we didn’t have the Internet, and learning how to program a main-frame computer didn’t look very exciting!

Reply to comment

1

Reply to comment