Math vs. Computer Science

What actually separates math from computer science? Obviously there is a large intersection between the two, but each of them has a distinctive feel. Is it just a “you know it when you see it” kind of distinction?

I don’t think so. And I think knowing what characterizes the two actually helps you become better at both, in particular because you know what broad class of techniques you should be focusing on.

Math and computer science, broadly speaking, both ask questions about the solutions to a certain problem. “What are the objects XX that satisfy some property PP?”

  1. Math is focused on studying the space of solutions, without necessarily providing a way to construct or explicitly understand individual instances of solutions.
  2. Computer science is focused on studying procedures to construct solutions, without necessarily providing you with a broad understanding of the space of solutions.

I think this is best explained through example.

Math: Borsuk-Ulam

Assume the Earth is a perfect sphere and temperature/air pressure vary continuously across its surface. There exist two diametrically opposed points with identical temperature and air pressure.

We will prove a simpler theorem. Consider the circle S1S^1 of radius 11 in \mathbb{C} and a continuous function f:S1>f : S^1 -> \mathbb{R}. Then there is a point xS1x \in S^1 such that f(x)=f(x)f(x) = f(-x).

Proof: Consider the function g(x)=f(x)f(x)g(x) = f(x) - f(-x). Observe g(x)=g(x)g(-x) = -g(x). Pick any xx; either g(x)=0g(x) = 0, in which case we are done, or not, in which case the Intermediate Value Theorem provides us with some yy between xx and x-x such that g(y)=0g(y) = 0.

(Note the zeroes of gg are precisely the points which f(x)=f(x)f(x) = f(-x).)

The Borsuk-Ulam theorem gives us insight into the solution space (i.e. that it is non-empty). This is a typical example of a “non-constructive proof”, where we learn that a solution exists, but the proof is no use for actually finding the solution.

Computer Science: The non-decreasing multiples of NN

The source is AtCoder ABC 443 Task F.

A number is called non-decreasing if its digits don’t decrease, e.g. 11231123. What is the smallest non-decreasing multiple of NN?

Solution

Perform BFS on the digits (only that we are allowed to revisit the same vertex multiple times), only going from a digit dd to digits that are d\geq d. Keep track of the remainder modulo NN by going from remainder rr to remainder (10r+d)%N(10 r + d) \% N whenever you visit digit dd.

Terminate the BFS when we reach a remainder of 00. The path we took corresponds to the smallest non-decreasing multiple of NN.

We can easily modify this solution to yield all non-decreasing multiples of NN (just don’t terminate) in increasing order. So we have a reasonably fast way to generate all such multiples of NN.

Yet this solution provides no insight into what properties these non-decreasing multiples of NN have. How many of them are there? How quickly do they grow? We have no idea.