Math In Computer Science: What, Why, & How Much


Math In Computer Science

Math can be the most frightening part of Computer Science. It’s true for those considering the major and for many students already semesters in. I know firsthand because I was one of those students. And with what I know today, I think I can save a lot of students some pain by giving some concrete information and equally solid advice. Here’s what you need to know about math in Computer Science.

Math In Computer Science

Most of the math that you actually use in Computer Science is learned in a specific math class called ‘Discrete Mathematics’. Discrete math has a diverse range of topics. However, the core topics are sets, sequences, graph theory, logic, probability, and statistics.

Sets

A Set is a collection of data, in no particular order. A set can contain numbers, characters, strings, or other objects. These objects aren’t always integers, as you would expect from a math class. However, this is the math of Computer Science. Also, any given set can contain more than one type of object. It’s also okay to have multiples of any given value inside a set.

Sets are one of the many different types of data structures. Let’s briefly look at an example of a set: Example: A = {3, 3, 0, a, {x, y, z}}

In this example, the set is named ‘A’ and the set contains the numbers 3, 3, and 0, followed by the character ‘a’, followed by a set including x, y, and z. Notice that they’re not in increasing order, and that’s okay. There are also more than one ‘3’. Sets may have a name or can be contained within another set as seen in our example.

Sequences

A Sequence is another collection of data. However, unlike a Set, the data in a sequence must be ordered and only deals with numbers. Similar to sets, however, sequences can and often do have repeating values.

Graph Theory

Graphs are another type of data structure. Thus, Graph Theory is the study of the structures that model relationships between objects. If you look at a graph (example below) you will see that it’s made up of circles, called nodes or vertices, which represent the objects. It’s also made up of lines, called edges, which connect each node and represent the relationship between them.

Graph Theory - Math in Computer Science


If this graph were on a piece of paper, would you be able to do the following? Traverse each edge in the graph and touch each node: a) without lifting your pencil, and b) without traversing any edge more than once. Is this possible? The answer is no. These are some of the types of problems that graph theory looks at.

Logic

Logic is all about the consequences of actions or arguments. Simply put, logical statements go, “If this, then that.” For example, consider the logical statement: If the time is 9:00 pm, then I’ll go to sleep. Not only is this my actual bedtime, but it’s a prime example of propositional logic.

Probability

Probability describes how likely something is to occur. For instance, if you have a complete, shuffled deck of 52 cards and you draw one at random. How likely is it that you will pick an Ace? (Answer: 1/13) How likely would it be to pick a Spade? (Answer: 1/4) Now, how likely would it be to pick an Ace of Spades? That only happens once in each deck of cards, so the probability is 1/52.

Statistics

Statistics is very closely linked to probability. Where probability shows how likely you are to pick an Ace, statistics describes the cards that were actually picked. But that’s not all. Statistics will then give some sort of reasoning for the resulting cards that were picked.

Why Do You Need Math For Computer Science

The reason we as students need to learn math alongside Computer Science is that Computer Science is founded in math. Computers are really just math machines at the lowest level. But even if you’re not working at the low-level when programming, you’re still likely to use algebra and PEMDAS (Parenthesis, Exponents, Multiplication, Division, Addition, and Subtraction).

There are other reasons you would need math for computer science. For brevity, I’ll just list a few places you’ll use math, as well as the kinds of maths.

  • Logical Programming (Algebra, Discrete Math)
  • Game Development (Calculus, Linear Algebra)
  • Machine Learning (Calculus, Linear Algebra, Probability, Statistics)
  • Data Science (Calculus, Linear Algebra, Probability, Statistics)
  • Distributed Systems (Graph Theory)

Math Classes In Computer Science (Bachelors Degree)

One question I’m often asked is: How much math is in a Computer Science degree? It varies from University to University, but Calculus, Linear Algebra, and Discrete Mathematics are very common. I’ve been to two Universities and they both have different math requirements. Let’s take a look at these two examples:

Purdue Northwest University

After two semesters of community college, I spent another two semesters at Purdue Northwest University. In the two semesters that I was at Purdue, I completed Calculus 1 and Calculus 2. Here’s a quick overview of all the math required for Purdue’s C.S. program.

  • Calculus 1: Differential (5 Credits)
  • Calculus 2: Integral (5 Credits)
  • Calculus 3: Multi-variable (5 Credits)
  • Linear Algebra (3 Credits)
  • Discrete Math (3 Credits)
  • Statistics (3 Credits)

Total Math Credits: 24

Governors State University

After I transferred to Governors State University, I realized the math requirements were quite different. I’ve only been here one semester, so I haven’t taken my final math yet. That said, here are all the math requirements for Governors State’s C.S. program.

  • Calculus 1: Differential (3 Credits)
  • Discrete Math (3 Credits)

Total Math Credits: 6

Should You Major In C.S. If You’re Bad At Math?

Poor math skills shouldn’t keep you from majoring in Computer Science. If you have a passion for the subject matter, you should be able to learn what you need to learn. Besides, not all Universities require a lot of math. You can see this clear as day from the previous example. However, you shouldn’t underestimate the work involved in getting your degree.

Computer Science is challenging but extremely rewarding. If you’re considering majoring in C.S., I would definitely check out my article answering the question: Is Computer Science Hard? There’s a lot of good information that will prepare you for some of the struggles you’ll face.

Tim Statler

Tim Statler is a Computer Science student at Governors State University and the creator of Comp Sci Central. He lives in Crete, IL with his wife, Stefanie, and their cats, Beyoncé and Monte. When he's not studying or writing for Comp Sci Central, he's probably just hanging out or making some delicious food.

Recent Posts