Wednesday, September 20, 2017
Coloring polygon vertices
The vertices of a regular $n$-gon ($n \geq 3$) are to be colored with one of the $k$ colors such that no two adjacent vertices may have the same color.
Let $f(n)$ be the number of legal coloring. Find a closed formula for $f(n)$.
Solution:
Suppose we sever one of the edges temporarily, so that we're left with a "string" of length $n$ where the first and last vertices are not connected. In order to color this string, we may color the first vertex $k$ ways, but each of the subsequent vertices may only be colored $k-1$ ways, avoiding the color of the previous vertex. Suppose $g(n)$ is the number of ways to color a string of length $n$, then $g(n) = k(k-1)^{n-1}$
Now, take one of these colored strings of length $n$ and join the first and last vertices. The resulting polygon may or may not be a valid coloring. It is not a valid coloring if and only if the first and last vertices have the same color. The number of such invalid coloring is the same as $f(n-1)$. There is a bijection between the invalid coloring where the first and last vertices have the same color and a valid coloring of an $(n-1)$-gon.
So:
$$f(n) = g(n) - f(n-1)$$
Now, $f(3) = k(k-1)(k-2)$. So:
$$f(4) = k(k-1)^3 - f(3) = k(k-1)(k^2 -3k+3) =(k-1)((k-1)^3+1)$$
$$f(5) = k(k-1)^4 - f(4) = k(k-1)(k^3-4k^2+6k-4) = (k-1)((k-1)^4-1)$$
$$f(6) = k(k-1)^5 - f(5) = (k-1)((k-1)^5+1)$$
So we can see a pattern, which we can prove via induction easily.
$$f(n) = (k-1)((k-1)^{n-1}+(-1)^n)$$
ODE discrete version
If $f$ is a function that is defined over natural numbers ($f:N \to R$), let $f^*$ denote the function $f^*(n) = f(n) - f(n-1)$.
Find all functions such that
$$n(f^*)^*(n) + (n-1)f^*(n) = f(n)$$
for all $n > 2$
Solution
We can check that $f(n) = A(n-1) + B/2^n$ for any constant $A,B$ satisfies the given equation. Now we show that there's nothing else.
Define $g = f^*+f$. The equation is identical to:
$$n(f^*+f)^*(n) =(f^*+f)(n)$$
$$ n(g(n) - g(n-1)) = ng^*(n) = g(n)$$
$$\frac{g(n)}{n} = \frac{g(n-1)}{n-1}$$
for all $n>2$, therefore $g(n)/n$ must be a constant. Remember that $g(1)$ is not defined because $f$ is only defined for $n \geq 1$ thus $g$ is only defined for $n \geq 2$. Furthermore, the value $g(2)$ depends on $f(1)$ and $f(2)$.
Case 1: $g(2) = 0$
In this case then $g(n) = 0 \forall n$.
$$(f^*+f)(n) = 0$$
$$f(n) = f(n-1)/2$$
so we easily get $f(n) = k/2^n$ for some constant $k$.
Case 1: $g(2) \neq 0$
Note that if $f$ is a solution to the problem then $kf$ is also a solution to the problem, for all $k$ real numbers. If we replace $f$ by $kf$, then $g$ is also replaced by $kg$. So WLOG, we may assume that $g(2) = 2$
Because $g(n) / n$ is a constant then
$$g(n) / n = g(2) / 2 = 1$$ so $g(n) = n \forall n >2$
$$f(n) = \frac{f(n-1) + n}{2}$$
for all $n > 2$.
Because $g(2) = 2 = 2f(2) - f(1)$ then $f(2) = 1+ f(1)/2$
Now notice this pattern:
$$f(3) = \frac{f(2) + 3}{2} = 2 + f(1)/4$$
$$f(4) = \frac{f(3) + 4}{2} = 3 + f(1)/8$$
Easy to prove by induction that $f(n) = n-1 + f(1)2^{1-n}$.
From the two cases above, it's clear that any solution of the equation must be in the form of $f(n) = A(n-1) + B/2^n$ for any constant $A,B$
Subscribe to:
Posts (Atom)