Read · 1 min
Invariants (Part 1)
Invariant is something that doesn't change after some operation. This is a very useful technique in maths, and we'll see a few applications of invariants.
Examples of invariant
For example, if we let denote the sum of digits of , then it is well-known that . So, we can say that the remainder upon division by of is invariant.
Consider this problem :
At first, a room is empty. Each minute, either one person enters or two people leaves. After exactly minutes, could the room contain exactly people?
The crucial fact is :
At any fixed time , all the possible values of population of the room differ from one another by multiples of 3.
Indeed, if there are people in the room, then after one minute, there could be or people. The difference between these two possible outcomes is . In minutes, one possible population is clearly , a multiple of , thus all possible populations must be a multiple of , so the answer is no.
A seemingly hard problem is solved instantly with invariants. This shows the power of invariance.