I was bored during lockdown, so I decided to start a blog about my random thoughts about math. It contains some solutions to math problems, and some 'simple' applications of math.
Friday, 25 September 2020
For what pairs of a and b is $a|b$ and $a+1|b+1$. where $|$ mean "is a divisors of".
There exist $p$ and $q$ so $ap=b$ and $(a+1)q = b+1$
Now is
$$b-a=ap-a=a(p-1)$$
$$b-a=(b+1)-(a+1)=(a+1)(q-1)$$
so
$$a(p-1)=(a+1)(q-1)$$
$a$ and $a+1$ cannot share any divisors so there exists an $n$ where $an=(q-1)$ and $(p-1)=n(a+1)$.
Solve to $p$ and $q$ to get $q = na+1$ and $p=na+n+1=q+n$. with $b=ap=na^2+na+a$, the pair becomes: $(a, na^2+na+a)$ for $a$ and $n$ any integer. These pairs contain all possible pairs.
Players place tokens on the map in succession. Token can be placed on any pixel that is a land tile, (so on plains, mountains and rivers), not in oceans. The first token of each player is placed randomly. From the second turn onwards, players can only place their token in their "sphere of influence".
Each pixel is in a player's sphere of influence if the player can travel from there to one of its tokens the quickest. It does not matter how fast you travel, or how many tokens are close, it only matters that your token is closer (in travel time) than any of your enemies' tokens.
Travel time is calculated as follows
Travelling over flat land takes 1 unit of time.
Travelling over mountains takes 1 to 10 units of time, depending on how mountainous it is.
Travelling over rivers or ocean takes 10 units of time
If all players have placed 10 tokens, the player who has the larger sphere of influence, land or water, wins.
The code for this game is open source and can be found here:
Image you have a circle of red and blue checkers. Between every two checkers, you add a red checker if they have the same colour, and a blue checker if they have a different colour. Then you remove the original tokens. You repeat this process indefinitely. For wat starting conditions does the circle end up with only red tokens?
The video gives a visual solution, but if this unrigorous solution is not satisfying, below is a more rigorous one:
A wheel as described in the problem is isomorph with the finite ring defined by:
$$\mathcal{W_n} = GF(2)[X]/(X^n+1)$$
Where for our isomorphism works as follows.
Let $\delta_0$ be 0 if the top token is red, and 1 is the top token is blue. The walk clockwise, and for each token you pass, perform the same procedure, but use $\delta_1$, $\delta_2$ and so on instead.
Now are element of our finite ring can be written as $$\sum_{i=0}^{n-1}\delta_ix^i$$
Summing two elements is evidently equivalent to combining two wheels (where we combine two the same tokens to a red token and two different tokens to a blue token). Each delta just follows the $$GF(2)$$ rules.
Rotating the system one turn clockwise, is equivalent to multiplying with $x$. This can be shown as follows
This means that our initially described operator is the same as multiplying our initial state $s$ with $x+1$.
So our system becomes only red tokens if and only if $$\exists a: s(x+1)^a\equiv0$$
Definition 1:
$$\mathcal{W_n} = GF(2)[X]/(X^n+1)$$
We call $\mathcal{W_n}$ a wheel and $n$ the size of the wheel. In words, a wheel with size $n$ is the quotient ring of of the polynomial ring over the second order galois field
Definition 2:
For any element $w \in \mathcal{W}$ the element has period $p$ if $$wx^p \equiv w$$ Note that an element can have multiple periods.
Trivially, each of the following statements are true:
The period is a divider of the size of the wheel.
If $p$ is a period, ever multiple is also a peroid.
If $a$ and $b$ are periods gcd$(a,b)$ is a period
if $a$ and $b$ have period $p$, so does $a+b$
if $a$ has period $p$, so does $ab$ for all $b$
Definition 3:
$$u \equiv \sum_{i=0}^{n-1}x^i$$
Theorem 1:
$$\forall a,b \in \mathcal{W_n} a \equiv b \Leftrightarrow a+b \equiv 0$$
Proof: Trivially follows from the fact that $a+a\equiv 0$ in GF(2)
Theorem 2:
$\forall a,b \in \mathcal{W_n}$ If $a(x+1) \equiv 0$ then $a \equiv 0$ or $a \equiv u$
From theorem 3 and 4 follow that our procedure will finish with all red tokens if and only if it has a period of a power of two. In other words, if there exists a power of two such that if I rotate the wheel with an amount of tokens equal to that power of two, if I end up with the same wheel. And in practice youonly have to check powers of two that are divisors of the size of the wheel, so there are not many cases to check.
Imagine there are 10 000 Thanosses on a planet, each having an infinity gauntlet. Each Thanos snaps its fingers ones, removing every other remaining Thanos with a change of 50%. After all Thanosses have either snapped there fingers or are disintegrated, what is the expected value of Thanosses remaining?
This riddle was inspired by the following riddle: https://fivethirtyeight.com/features/how-many-earthlings-would-survive-63-thanos-snaps/
You can watch the following video made with a horrible automatic voice, or read further to see the same argument layed out in text.
There are two kinds of Thanosses. One kind of Thanos is a Thanos that still has to snap it's fingers, in other words, that has a working gauntlet. Let us call this kind of Thanos an active Thanos. The other kind of Thanos is the Thanos that has already snapped it's fingers. It has no working gauntlet, and is therefore harmless. We call this kind of Thanos a passive Thanos.
If we forget for a moment the Thanos that is currently snapping, each other thanos has a chance of exactly one half to be disintegrated. This can be modelled by each Thanos flipping a coin.
Head means Thanos survives
Tail means Thanos dies
The distribution of the number of heads, and by consequence, the number of remaining Thanosses, can be described by the binomial distribution, with p being $1/2$.
Now, for each snap, there are 3 different kinds of Thanosses,
Snapping Thanos (1 active): chance of 1 to have 1 passive Thanos
Other active Thanosses ($a-1$ active): chance of $$\binom{k}{a-1}\frac{1}{2^{a-1}}$$ to have $k$ active Thanosses
passive Thanosses ($p$ passive): chance of $$\binom{l}{p}\frac{1}{2^{p}}$$ to have $l$ active Thanosses
We can combine these equations to write what the chances are to remain with exactly k active and l plus one passive thanosses.
We can also look at what happens if we add an extra passive Thanos. This new passive Thanos does not affect the survival chance of any of the other Thanosses. It's survival chance is only affected by the number of remaining active Thanosses. This means that we can split the system in a part dependant on the active and on the passive Thanosses.
$$E(a,p+1) = E(a,p) + P(a)$$
where $P(a)$ is a single passive Thanos's survival chance.
Combining this with the fact that the expected value equals the sum of each of the chances times the expected value of each corresponding system gives us a nice recursive formula for the expected value.
The value of the base case equals two, so the value of all other elements must also be two. This means that whenever there are two passive thanosses, the expected value will equal two. If there are less then two passive thanosses, like in our actual problem statement where there are zero, the number of remaining thanosses is less then two.
This simplifies our solution to the following equations.
There is no nice formula for P, but it can be generated by a computer program. The following rust program generates all the values
use statrs::distribution::{Binomial, Discrete};
fn main() { let mut p: Vec<f64> = vec![0.0; 100001 as usize]; p[0] = 1.0; for n in 1usize..(1<<20) { let binom = Binomial::new(0.5, (n-1) as u64).unwrap(); for k in 0usize..n { p[n] += binom.pmf(k as u64) * p[k] * 0.5 ; } if vec![1,100,1000,10000,100000].iter().any(|x| *x == n) { println!("{} & {} &{} \\\\",n,p[n],2.0-2.0*p[n]); } } }
Running our program and taking the 10 000 result nicely gives us our solution of 1.999711521253186 which is very close to two, as expected.