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 that satisfy some property ?”
- Math is focused on studying the space of solutions, without necessarily providing a way to construct or explicitly understand individual instances of solutions.
- 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 of radius in and a continuous function . Then there is a point such that .
Proof: Consider the function . Observe . Pick any ; either , in which case we are done, or not, in which case the Intermediate Value Theorem provides us with some between and such that .
(Note the zeroes of are precisely the points which .)
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
The source is AtCoder ABC 443 Task F.
A number is called non-decreasing if its digits don’t decrease, e.g. . What is the smallest non-decreasing multiple of ?
Solution
Perform BFS on the digits (only that we are allowed to revisit the same vertex multiple times), only going from a digit to digits that are . Keep track of the remainder modulo by going from remainder to remainder whenever you visit digit .
Terminate the BFS when we reach a remainder of . The path we took corresponds to the smallest non-decreasing multiple of .We can easily modify this solution to yield all non-decreasing multiples of (just don’t terminate) in increasing order. So we have a reasonably fast way to generate all such multiples of .
Yet this solution provides no insight into what properties these non-decreasing multiples of have. How many of them are there? How quickly do they grow? We have no idea.