Small fixes
This commit is contained in:
parent
6c694da7a8
commit
e79e59a839
|
@ -621,8 +621,7 @@ Let $x^{-1}_m$ be the inverse of $x$ modulo $m$, and
|
||||||
\[ X_k = \frac{m_1 m_2 \cdots m_n}{m_k}.\]
|
\[ X_k = \frac{m_1 m_2 \cdots m_n}{m_k}.\]
|
||||||
Using this notation, a solution to the equations is
|
Using this notation, a solution to the equations is
|
||||||
\[x = a_1 X_1 {X_1}^{-1}_{m_1} + a_2 X_2 {X_2}^{-1}_{m_2} + \cdots + a_n X_n {X_n}^{-1}_{m_n}.\]
|
\[x = a_1 X_1 {X_1}^{-1}_{m_1} + a_2 X_2 {X_2}^{-1}_{m_2} + \cdots + a_n X_n {X_n}^{-1}_{m_n}.\]
|
||||||
In this solution, it holds for each number
|
In this solution, for each $k=1,2,\ldots,n$,
|
||||||
$k=1,2,\ldots,n$ that
|
|
||||||
\[a_k X_k {X_k}^{-1}_{m_k} \bmod m_k = a_k,\]
|
\[a_k X_k {X_k}^{-1}_{m_k} \bmod m_k = a_k,\]
|
||||||
because
|
because
|
||||||
\[X_k {X_k}^{-1}_{m_k} \bmod m_k = 1.\]
|
\[X_k {X_k}^{-1}_{m_k} \bmod m_k = 1.\]
|
||||||
|
@ -722,6 +721,6 @@ and the number 12 is not prime, because
|
||||||
Hence, Wilson's theorem can be used to find out
|
Hence, Wilson's theorem can be used to find out
|
||||||
whether a number is prime. However, in practice, the theorem cannot be
|
whether a number is prime. However, in practice, the theorem cannot be
|
||||||
applied to large values of $n$, because it is difficult
|
applied to large values of $n$, because it is difficult
|
||||||
to calculate the value of $(n-1)!$ when $n$ is large.
|
to calculate values of $(n-1)!$ when $n$ is large.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ As an example, consider the problem
|
||||||
of counting the number of ways to
|
of counting the number of ways to
|
||||||
represent an integer $n$ as a sum of positive integers.
|
represent an integer $n$ as a sum of positive integers.
|
||||||
For example, there are 8 representations
|
For example, there are 8 representations
|
||||||
for the number $4$:
|
for $4$:
|
||||||
\begin{multicols}{2}
|
\begin{multicols}{2}
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item $1+1+1+1$
|
\item $1+1+1+1$
|
||||||
|
@ -59,7 +59,10 @@ f(3) & = & 4 \\
|
||||||
f(4) & = & 8 \\
|
f(4) & = & 8 \\
|
||||||
\end{array}
|
\end{array}
|
||||||
\]
|
\]
|
||||||
It turns out that the function also has a closed-form formula
|
|
||||||
|
Sometimes, a recursive formula can be replaced
|
||||||
|
with a closed-form formula.
|
||||||
|
In this problem,
|
||||||
\[
|
\[
|
||||||
f(n)=2^{n-1},
|
f(n)=2^{n-1},
|
||||||
\]
|
\]
|
||||||
|
@ -316,7 +319,7 @@ there are 6 solutions:
|
||||||
In this scenario, we can assume that
|
In this scenario, we can assume that
|
||||||
$k$ balls are initially placed in boxes
|
$k$ balls are initially placed in boxes
|
||||||
and there is an empty box between each
|
and there is an empty box between each
|
||||||
pair of two adjacent boxes.
|
two adjacent boxes.
|
||||||
The remaining task is to choose the
|
The remaining task is to choose the
|
||||||
positions for the remaining empty boxes.
|
positions for the remaining empty boxes.
|
||||||
There are $n-2k+1$ such boxes and
|
There are $n-2k+1$ such boxes and
|
||||||
|
@ -354,7 +357,7 @@ $n$ left parentheses and $n$ right parentheses.
|
||||||
For example, $C_3=5$, because
|
For example, $C_3=5$, because
|
||||||
we can construct the following parenthesis
|
we can construct the following parenthesis
|
||||||
expressions using three
|
expressions using three
|
||||||
left parentheses and three right parentheses:
|
left and right parentheses:
|
||||||
|
|
||||||
\begin{itemize}[noitemsep]
|
\begin{itemize}[noitemsep]
|
||||||
\item \texttt{()()()}
|
\item \texttt{()()()}
|
||||||
|
@ -411,7 +414,8 @@ not counting the outermost parentheses
|
||||||
\item $C_{n-i-1}$: the number of ways to construct an
|
\item $C_{n-i-1}$: the number of ways to construct an
|
||||||
expression using the parentheses of the second part
|
expression using the parentheses of the second part
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
In addition, the base case is $C_0=1$,
|
|
||||||
|
The base case is $C_0=1$,
|
||||||
because we can construct an empty parenthesis
|
because we can construct an empty parenthesis
|
||||||
expression using zero pairs of parentheses.
|
expression using zero pairs of parentheses.
|
||||||
|
|
||||||
|
@ -442,10 +446,10 @@ the expression becomes \texttt{)((()(}.
|
||||||
|
|
||||||
The resulting expression consists of $n+1$
|
The resulting expression consists of $n+1$
|
||||||
left parentheses and $n-1$ right parentheses.
|
left parentheses and $n-1$ right parentheses.
|
||||||
The number of such expressions is ${2n \choose n+1}$
|
The number of such expressions is ${2n \choose n+1}$,
|
||||||
that equals the number of non-valid
|
which equals the number of non-valid
|
||||||
parenthesis expressions.
|
parenthesis expressions.
|
||||||
Thus the number of valid parenthesis
|
Thus, the number of valid parenthesis
|
||||||
expressions can be calculated using the formula
|
expressions can be calculated using the formula
|
||||||
\[{2n \choose n}-{2n \choose n+1} = {2n \choose n} - \frac{n}{n+1} {2n \choose n} = \frac{1}{n+1} {2n \choose n}.\]
|
\[{2n \choose n}-{2n \choose n+1} = {2n \choose n} - \frac{n}{n+1} {2n \choose n} = \frac{1}{n+1} {2n \choose n}.\]
|
||||||
|
|
||||||
|
@ -541,7 +545,7 @@ the intersections are known, and vice versa.
|
||||||
A simple example of the technique is the formula
|
A simple example of the technique is the formula
|
||||||
\[ |A \cup B| = |A| + |B| - |A \cap B|,\]
|
\[ |A \cup B| = |A| + |B| - |A \cap B|,\]
|
||||||
where $A$ and $B$ are sets and $|X|$
|
where $A$ and $B$ are sets and $|X|$
|
||||||
is the size of a set $X$.
|
denotes the size of $X$.
|
||||||
The formula can be illustrated as follows:
|
The formula can be illustrated as follows:
|
||||||
|
|
||||||
\begin{center}
|
\begin{center}
|
||||||
|
@ -614,7 +618,7 @@ As an example, let us count the number of \key{derangements}
|
||||||
of elements $\{1,2,\ldots,n\}$, i.e., permutations
|
of elements $\{1,2,\ldots,n\}$, i.e., permutations
|
||||||
where no element remains in its original place.
|
where no element remains in its original place.
|
||||||
For example, when $n=3$, there are
|
For example, when $n=3$, there are
|
||||||
two possible derangements: $(2,3,1)$ and $(3,1,2)$.
|
two derangements: $(2,3,1)$ and $(3,1,2)$.
|
||||||
|
|
||||||
One approach for solving the problem is to use
|
One approach for solving the problem is to use
|
||||||
inclusion-exclusion.
|
inclusion-exclusion.
|
||||||
|
@ -676,7 +680,7 @@ with some other element than 1.
|
||||||
Now we have to construct a derangement
|
Now we have to construct a derangement
|
||||||
of $n-1$ element, because we cannot replace
|
of $n-1$ element, because we cannot replace
|
||||||
the element $x$ with the element $1$, and all other
|
the element $x$ with the element $1$, and all other
|
||||||
elements should be changed.
|
elements must be changed.
|
||||||
|
|
||||||
\section{Burnside's lemma}
|
\section{Burnside's lemma}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ is a vector that contains three elements.
|
||||||
\index{transpose}
|
\index{transpose}
|
||||||
|
|
||||||
The \key{transpose} $A^T$ of a matrix $A$
|
The \key{transpose} $A^T$ of a matrix $A$
|
||||||
is obtained when the rows and columns in $A$
|
is obtained when the rows and columns of $A$
|
||||||
are swapped, i.e., $A^T[i,j]=A[j,i]$:
|
are swapped, i.e., $A^T[i,j]=A[j,i]$:
|
||||||
\[
|
\[
|
||||||
A^T =
|
A^T =
|
||||||
|
@ -541,9 +541,9 @@ X^n \cdot
|
||||||
\end{bmatrix}.
|
\end{bmatrix}.
|
||||||
\]
|
\]
|
||||||
The value of $X^n$ can be calculated in
|
The value of $X^n$ can be calculated in
|
||||||
$O(k^3 \log n)$ time,
|
$O(\log n)$ time,
|
||||||
so the value of $f(n)$ can also be calculated
|
so the value of $f(n)$ can also be calculated
|
||||||
in $O(k^3 \log n)$ time.
|
in $O(\log n)$ time.
|
||||||
|
|
||||||
\subsubsection{General case}
|
\subsubsection{General case}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ corresponds to the set
|
||||||
\[A = \{2,4,6\}.\]
|
\[A = \{2,4,6\}.\]
|
||||||
|
|
||||||
Each outcome $x$ is assigned a probability $p(x)$.
|
Each outcome $x$ is assigned a probability $p(x)$.
|
||||||
Furthermore, the probability $P(A)$ of an event
|
Then, the probability $P(A)$ of an event
|
||||||
$A$ can be calculated as a sum
|
$A$ can be calculated as a sum
|
||||||
of probabilities of outcomes using the formula
|
of probabilities of outcomes using the formula
|
||||||
\[P(A) = \sum_{x \in A} p(x).\]
|
\[P(A) = \sum_{x \in A} p(x).\]
|
||||||
|
@ -169,7 +169,7 @@ Hence, when calculating the
|
||||||
probability of $A$, we only consider the outcomes
|
probability of $A$, we only consider the outcomes
|
||||||
that also belong to $B$.
|
that also belong to $B$.
|
||||||
|
|
||||||
Using the above sets,
|
Using the previous sets,
|
||||||
\[P(A | B)= 1/3,\]
|
\[P(A | B)= 1/3,\]
|
||||||
because the outcomes of $B$ are
|
because the outcomes of $B$ are
|
||||||
$\{1,2,3\}$, and one of them is even.
|
$\{1,2,3\}$, and one of them is even.
|
||||||
|
@ -409,7 +409,7 @@ $[p_1,p_2,\ldots,p_n]$, where $p_k$ is the
|
||||||
probability that the current state is $k$.
|
probability that the current state is $k$.
|
||||||
The formula $p_1+p_2+\cdots+p_n=1$ always holds.
|
The formula $p_1+p_2+\cdots+p_n=1$ always holds.
|
||||||
|
|
||||||
In the example, the initial distribution is
|
In the above scenario, the initial distribution is
|
||||||
$[1,0,0,0,0]$, because we always begin in floor 1.
|
$[1,0,0,0,0]$, because we always begin in floor 1.
|
||||||
The next distribution is $[0,1,0,0,0]$,
|
The next distribution is $[0,1,0,0,0]$,
|
||||||
because we can only move from floor 1 to floor 2.
|
because we can only move from floor 1 to floor 2.
|
||||||
|
@ -428,7 +428,7 @@ a walk of $m$ steps in $O(n^2 m)$ time.
|
||||||
The transitions of a Markov chain can also be
|
The transitions of a Markov chain can also be
|
||||||
represented as a matrix that updates the
|
represented as a matrix that updates the
|
||||||
probability distribution.
|
probability distribution.
|
||||||
In this example, the matrix is
|
In the above scenario, the matrix is
|
||||||
|
|
||||||
\[
|
\[
|
||||||
\begin{bmatrix}
|
\begin{bmatrix}
|
||||||
|
@ -543,7 +543,7 @@ When each element $x$ is randomly chosen,
|
||||||
the size of the array about halves at each step,
|
the size of the array about halves at each step,
|
||||||
so the time complexity for
|
so the time complexity for
|
||||||
finding the $k$th order statistic is about
|
finding the $k$th order statistic is about
|
||||||
\[n+n/2+n/4+n/8+\cdots \le 2n = O(n).\]
|
\[n+n/2+n/4+n/8+\cdots < 2n = O(n).\]
|
||||||
|
|
||||||
The worst case of the algorithm requires still $O(n^2)$ time,
|
The worst case of the algorithm requires still $O(n^2)$ time,
|
||||||
because it is possible that $x$ is always chosen
|
because it is possible that $x$ is always chosen
|
||||||
|
|
|
@ -19,7 +19,7 @@ used in those games to other games.
|
||||||
|
|
||||||
Let us consider a game where there is initially
|
Let us consider a game where there is initially
|
||||||
a heap of $n$ sticks.
|
a heap of $n$ sticks.
|
||||||
Players $A$ and $B$ move alternatively,
|
Players $A$ and $B$ move alternately,
|
||||||
and player $A$ begins.
|
and player $A$ begins.
|
||||||
On each move, the player has to remove
|
On each move, the player has to remove
|
||||||
1, 2 or 3 sticks from the heap,
|
1, 2 or 3 sticks from the heap,
|
||||||
|
@ -227,7 +227,7 @@ to other games.
|
||||||
|
|
||||||
There are $n$ heaps in nim,
|
There are $n$ heaps in nim,
|
||||||
and each heap contains some number of sticks.
|
and each heap contains some number of sticks.
|
||||||
The players move alternatively,
|
The players move alternately,
|
||||||
and on each turn, the player chooses
|
and on each turn, the player chooses
|
||||||
a heap that still contains sticks
|
a heap that still contains sticks
|
||||||
and removes any number of sticks from it.
|
and removes any number of sticks from it.
|
||||||
|
@ -367,7 +367,7 @@ strategy used in nim to all games that fulfil
|
||||||
the following requirements:
|
the following requirements:
|
||||||
|
|
||||||
\begin{itemize}[noitemsep]
|
\begin{itemize}[noitemsep]
|
||||||
\item There are two players who move alternatively.
|
\item There are two players who move alternately.
|
||||||
\item The game consists of states, and the possible moves
|
\item The game consists of states, and the possible moves
|
||||||
in a state do not depend on whose turn it is.
|
in a state do not depend on whose turn it is.
|
||||||
\item The game ends when a player cannot make a move.
|
\item The game ends when a player cannot make a move.
|
||||||
|
@ -442,7 +442,7 @@ and the Grundy number of a winning state is
|
||||||
a positive number.
|
a positive number.
|
||||||
|
|
||||||
The Grundy number of a state corresponds to
|
The Grundy number of a state corresponds to
|
||||||
a number of sticks in a nim heap.
|
the number of sticks in a nim heap.
|
||||||
If the Grundy number is 0, we can only move to
|
If the Grundy number is 0, we can only move to
|
||||||
states whose Grundy numbers are positive,
|
states whose Grundy numbers are positive,
|
||||||
and if the Grundy number is $x>0$, we can move
|
and if the Grundy number is $x>0$, we can move
|
||||||
|
|
Loading…
Reference in New Issue