## Saturday, June 1, 2013

### When the game ends? (I)

Question: Consider a two-players' game.  Both players have equal chance of winning at each round. The game ends if one player wins two more rounds than the other.  What is the probability function for the number of rounds?

AA
BB
ABAA
ABBB
BAAA
BABB
ABABAA
ABABBB
ABBAAA
ABBABB
BAABAA
BAABBB
BABAAA
BABABB
......
Possible scenarios

Answer: Let $N$ be the number of rounds. $N$ cannot be odd, otherwise the difference of rounds won by the two players could not be 2.
Therefore $N$ is even, say $N=2k$. Each player has to win exactly one of $2r-1$-th and $2r$-th round for $1\le r\le k-1$ and then one player has to win the last two games.
In other words, the pattern should be $[..][..]...[..](..)$, the first $k-1$ $[..]$'s should be AB or BA, and the last $(..)$ is AA or BB.
Summing up, we know

$P(N=2k-1)=0, P(N=2k)=(1/2)^k$ for $k=1,2,\ldots$

The game most likely ended in 2 rounds, but the expected number of rounds is $\sum_{k=1}^\infty\frac{2k}{2^k}=4$.

## Wednesday, May 22, 2013

### Probability again, a ball game.

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

Question: Player A and Player B compete in a ball game. Player A has a chance of $p$ to earn a point, and Player B has a chance $q=1-p$ to earn a point. The game ends whenever a player gets 10 points. Now Player A has 7 points and Player B has 5 points. What is the probability that Player A wins the game?

A tennis game

Answer: Player A has to win 3 more points. Before Player A wins the last point, Player B can only wins no more than 4 points.

Method 1. Let $n$ be the number of further games. $n$ can be 3,4,5,...,7. If $n=3$, then Player A wins all the games, the probability is $p^3$. If $n=4$, then Player B may win one of the first 3 games, the probability is $C_1^3p^3q$. For general $n$, Player B may win any $n-3$ of the first $n-1$ games, and the probability is $C_{n-3}^{n-1}p^3q^{n-3}$. Summing up, we have $$P(A)=\left(\sum_{n=3}^7 C_{n-3}^{n-1} q^{n-3}\right)p^3=(1+3q+6q^2+10q^3+15q^4)p^3.$$
Method 2. If we use $a$ to represent the event that Player A earns a point and we use $b$ to represent the event that Player B earns a point, then $$\begin{eqnarray*} &&(1+b+b^2+\ldots)a(1+b+b^2+\ldots)a(1+b+b^2+\ldots)a\\ &=&(1+b+b^2+b^3+b^4+\ldots)^3a^3\\ &=&(1+3b+6b^2+10b^3+15b^4+\ldots)a^3 \end{eqnarray*}$$ consists of all the cases that Player A earns 3 more points. It is easy to see that only up to $b^4$ corresponding to that Player A wins the game. Therefore we have $$P(A)=(1+3q+6q^2+10q^3+15q^4)p^3.$$
The two methods are essentially the same. In the second method, the counting is hidden behind the algebra and we do not need to consider case by case.

## Sunday, May 12, 2013

### Winner becomes the dealer

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

Question: There is a card game between a dealer and a non-dealer. The odds that the dealer wins to that the other player wins is $p$:$q$. In a scenario, a poor guy with $1$ coins play against a rich guy with $N-1$ coins such that (1) initially the poor guy is the dealer, (2) after each game the winner gets $1$ coin from the loser and becomes the dealer in the next game and (3) no more games if one of the guys collect all the $N$ coins. What is the probability that the poor guy gets the final laugh?

Two-player mahjong is such a winner-becomes-the-dealer game.

Answer: Just like the usual gambler's ruin, we consider the moment that the poor guy having $n$ coins and calculate the probability that he will be the final winner at this moment. However, the chance of winning the current game depends on whether he is the dealer or not, we have to separate the two sub-cases, therefore we have $P_n$ be the probability that he will be the final winner if he is now the dealer and $Q_n$ be the probability that he will be the final winner if he is not the dealer.

We have $$\begin{eqnarray} P_n&=&\frac{p}{p+q}P_{n+1}+\frac{q}{p+q}Q_{n-1}...(1)\\ Q_n&=&\frac{q}{p+q}P_{n+1}+\frac{p}{p+q}Q_{n-1}...(2) \end{eqnarray}$$ with initial conditions $P_0=Q_0=0, P_N=Q_N=1$.

Now $$\begin{eqnarray*} P_{n+1}&=&\frac{p}{p+q}P_{n+2}+\frac{q}{p+q}Q_{n}\\ &=&\frac{p}{p+q}P_{n+2}+\frac{q}{p+q}\left(\frac{q}{p+q}P_{n+1}+\frac{p}{p+q}Q_{n-1}\right). \end{eqnarray*}$$ Rearranging the terms, $$\begin{eqnarray*} \left(1+\frac{q}{p+q}\right)P_{n+1}&=&P_{n+2}+\frac{q}{p+q}Q_{n-1}\\ &=&P_{n+2}+\left(P_n-\frac{p}{p+q}P_{n+1}\right). \end{eqnarray*}$$ Hence $$2P_{n+1}=P_{n+2}+P_n.$$ Using standard technique we have $$P_n=a+bn$$ for some fixed $a$ and $b$. Substitute it back, we have $$Q_n=a+b\left(n+\frac{q-p}{q}\right).$$ Now we turn our eyes to the initial conditions, and we will find that there are no $a$ and $b$ that can satisfy all four! What happens? It turns out that in this scenario, it is not logical to the poor guy to lose all the coins but wins the last game or to win all the coins but lose the last game. Indeed $P_0$ and $Q_N$ could not enter equations (1) and (2). It means we only consider $P_N=1$ and $Q_0=0$, and so $$a=\frac{p-q}{q}\left(N+\frac{p-q}{q}\right)^{-1}, b=\left(N+\frac{p-q}{q}\right)^{-1}$$ Putting all together, $$\begin{eqnarray*} P_n&=&\frac{n+\frac{p-q}{q}}{N+\frac{p-q}{q}}\\ Q_n&=&\frac{n}{N+\frac{p-q}{q}} \end{eqnarray*}$$ The final answer is $P_1=\frac{1+\frac{p-q}{q}}{N+\frac{p-q}{q}}$.

## Friday, May 10, 2013

### Nine squares

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

Question: There are 9 squares, 3 black and 6 red. In each turn, a square is chosen randomly and its color is then switched. The process continues until all squares have the same color. What is the probability that all squares are red at the end?

 RED RED BLACK BLACK RED RED RED RED BLACK

Answer: Let $P_k$ be the probability of all red at the end if currently there are $k$ red squares. Note in that turn, there are $\frac{k}9$ chance that a red square turns black and $\frac{9-k}9$ chance that a black square turns red. Therefore $$P_k=\frac{k}{9}P_{k-1}+\frac{k}{9}P_{k+1}, k=1,2,\ldots,8. P_0=0, P_9=1$$ Or in matrix notation, $$\begin{pmatrix}P_0\\P_1\\P_2\\P_3\\P_4\\P_5\\P_6\\P_7\\P_8\\P_9\end{pmatrix}= \begin{pmatrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 1/9 & 0 & 8/9 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 2/9 & 0 & 7/9 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 3/9 & 0 & 6/9 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 4/9 & 0 & 5/9 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 5/9 & 0 & 4/9 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 6/9 & 0 & 3/9 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 7/9 & 0 & 2/9 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 8/9 & 0 & 1/9 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{pmatrix} \begin{pmatrix}P_0\\P_1\\P_2\\P_3\\P_4\\P_5\\P_6\\P_7\\P_8\\P_9\end{pmatrix}$$ Hence $$\begin{pmatrix}P_0\\P_1\\P_2\\P_3\\P_4\\P_5\\P_6\\P_7\\P_8\\P_9\end{pmatrix} =\begin{pmatrix}0 \\ 35/83 \\ 315/664 \\ 325/664 \\ 165/332 \\ 167/332 \\ 339/664 \\ 349/664 \\ 48/83 \\ 1\end{pmatrix}.$$ Therefore the required probability is $P_6=\frac{339}{664}$ is just barely greater than $1/2$.

## Friday, May 3, 2013

### A probability game

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

Question: At each turn, if Player A has $p$ coins and Player B has $n-p$ coins, then the chance of A wins to the chance of B wins is $p:n-p$ and that whoever wins gain 1 coin from the loser. The game ends if a player gets all the $n$ coins. If currently A has $n_A$ coins and B has $n-n_A$ coins, what is the probability that A is the final winner?

A B
Wealth: $p$ coins Wealth: $n-p$ coins
Winning chance: $p/n$ Winning chance: $1-p/n$

Answer: Let $P_p$ denotes the probability that A is the final winner if A has $p$ coins. Then $$P_p=\frac{p}{n}P_{p+1}+\frac{n-p}{n}P_{p-1}, P_0=0, P_n=1.$$ Then $$\frac{n-p}{n}(P_p-P_{p-1})=\frac{p}{n}(P_{p+1}-P_p)$$ and thus $$P_{p+1}-P_p=\frac{n-p}{p}(P_p-P_{p-1})=\frac{(n-p)(n-(p-1))\cdots(n-1)}{p(p-1)\cdots1}(P_1-P_0)=C_p^{n-1}P_1.$$ Sum over all $P_p$ from $p=0$ to $r-1$, we have $$P_r=\sum_{p=0}^{r-1}(P_{r+1}-P_r)=\sum_{p=0}^{r-1} C_p^{n-1}P_1.$$ Consider the case $r=n$. $$1=\sum_{p=0}^{n-1} C_p^{n-1}P_1=2^{n-1}P_1$$ and hence $$P_1=\frac{1}{2^{n-1}}.$$ The final answer is therefore $$P_{n_A}=\frac{\sum_{p=0}^{n_A-1} C_p^{n-1}}{2^{n-1}}.$$
The wealthier or more powerful A is, the higher the chance A wins each battle. A reasonable model, isn't it?

## Friday, April 26, 2013

### bogus numbers?

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

I have read an article who claims that complex numbers does not exist and any physics based on complex numbers are bogus science!

I am surprised that in 21st century there are still such idiots dare to write like that. Anyway, his key argument is the following:

Consider the system of two equations $$\begin{cases}(x-1)^2+(y-1)^2=1 \\ x+y=0\end{cases}$$ the first of which is a circle centered at (1,1) of radius 1 and the second of which is a straight line passing (0,0) and (1,-1). The system has complex roots, but the geometric objects have no intersection. Therefore, the complex roots are bogus.

Question: What is wrong with his argument?

Answer: Only when we consider $x$ and $y$ as real numbers, the two equations correspond to the two geometric objects.

There are three ways to understand complex numbers.

The simplest way is that $a+\sqrt{-1}b$ is the point $(a,b)$ on a plane. In this case $(x-1)^2+(y-1)^2=0$ and $x+y=0$ each describes a relation between two points and therefore both are equations for a two-dimensional figure in a four-dimensional space. We cannot visualize four-dimensional space!

The second way is to consider $a+\sqrt{-1}b$ as the polynomial $ax+b$ in the space of polynomials in such a way that we identify the polynomials $x^2$ and $-1$. The two equations are therefore relations among two polynomials.

The third way is to consider $a+\sqrt{-1}b$ as the matrix $\begin{pmatrix}a & b \\ -b & a\end{pmatrix}$. The sum and product of two complex numbers are the sum and prodcut of two matrices.

Why does the author write such article? Because Stephen Hawking talks about complex numbers in physics and he also argues that we do not need God in science!

## Friday, April 19, 2013

### multiple of 11

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

Question: What are the smallest and largest multiples of 11 that are made up of the nine digits 1,2,3,4,5,6,7,8,9?

123456789
123456798
123456879
123456897
123457689
123457698
123457869
123457896
123457968
123457986
..................
..................
..................
987654312
987654321

If $A=a_1a_2a_3a_4a_5a_6a_7a_8a_9$ is a multiple of 11, then we know the difference $(a_1+a_3+a_5+a_7+a_9)-(a_2+a_4+a_6+a_8)$ is also a multiple of 11, say $11x$.

Note that $a_1+a_2+\cdots+a_9=1+2+\cdots+9=45$ and hence $a_1+a_3+a_5+a_7+a_9=(45+11x)/2$ and $a_2+a_4+a_6+a_8=(45-11x)/2$.

Note that if $x=3$, then $a_2+a_4+a_6+a_8=6$ which is impossible. Likewise $x\ne -3$. Therefore $x$ can only be $1$ or $-1$.

Therefore either $a_1+a_3+a_5+a_7+a_9=28, a_2+a_4+a_8+a_9=17$ or $a_1+a_3+a_5+a_7+a_9=17, a_2+a_4+a_8+a_9=28$.

To get the smallest multiple of 11, we would like to see $A=12345\ldots$. Both $1+3+5+a_7+a_9=28$ and $1+3+5+a_7+a_9=17$ are impossible (the latter one is possible only if $\{a_7, a_9\}=\{2,6\}$ but we already have $a_2=6$.).

Try $A=1234\ldots$. Now $1+3+a_5+a_7+a_9=28$ is possible if $\{a_5,a_7,a_9\}=\{7,8,9\}$ (and so $\{a_6,a_8\}=\{5,6\}$) but $1+3+a_5+a_7+a_9=17$ is impossible. Therefore the smallest multiple of 11 is $A=123475869$.

To get the largest multiple of 11, we would like to see $A=98765\ldots$. Now $9+7+5+a_7+a_9=28$ is possible if $\{a_7,a_9\}=\{3,4\}$ (and so $\{a_6,a_8\}=\{1,2\}$). Thus the largest multiple of 11 is $A=987652413$.

## Friday, April 12, 2013

### Arithmetic sequence of primes

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

Question: Suppose a, a+d, a+2d, ..., a+(n-1)d are primes. Find the largest possible n, under the condition that d cannot be a mulitple of 10.

    2     3     5     7    11    13    17    19    23    29
31    37    41    43    47    53    59    61    67    71
73    79    83    89    97   101   103   107   109   113
127   131   137   139   149   151   157   163   167   173
179   181   191   193   197   199   211   223   227   229
233   239   241   251   257   263   269   271   277   281
283   293   307   311   313   317   331   337   347   349
353   359   367   373   379   383   389   397   401   409
419   421   431   433   439   443   449   457   461   463
467   479   487   491   499   503   509   521   523   541
547   557   563   569   571   577   587   593   599   601
607   613   617   619   631   641   643   647   653   659
661   673   677   683   691   701   709   719   727   733
739   743   751   757   761   769   773   787   797   809
811   821   823   827   829   839   853   857   859   863
877   881   883   887   907   911   919   929   937   941
947   953   967   971   977   983   991   997

(Table of primes up to 1000)

Answer: Lets make a guess. We claim the largest possible n≥5.

a must be odd, otherwise a+2d is an even number greater than 2 and thus not a prime.

If d is odd, then a+d is an even prime greater than 2 and thus not a prime.

If d is even and not a multiple of 10, then one of a, a+d, a+2d, a+3d, a+4d have the last digit being 5 and hence it must be 5. Note that there is only one odd prime, i.e. 3, which is smaller than 5. Therefore it is only possible if a=5 or a+d=5.

If a+d=5 then a=3, d=2. The sequence is just 3,5,7.

The only case left is that a=5 and then a+5d is a multiple of 5. Therefore n is at most 5.

You can try to search using the table.

5, 11, 17, 23, 29 is a prime sequence with d=6.
5, 17, 29, 41, 53 is a prime sequence with d=12.

Therefore the largest possible n=5.

What if d is allowed to be a multiple of 10?

No matter how large n is, we can construct a sequence a, a+d, a+2d, ..., a+(n-1)d of primes. It is the famous Green-Tao theorem, proved by Ben Green and Terence Tao in 2004.

## Friday, April 5, 2013

### 1, 11, 111, 1111 ....

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

(Easter Holiday gives me another excuse to be lazy....)

A simple number theory question: Show that there is at least one (and hence infinitely many) multiples of p among 1b, 11b, 111b, 1111b, 11111b,... for all but finitely many prime numbers p. Here 11111b etc are numbers written with base b numerals.

Answer after the good-looking easter eggs :P

Let n(k)=111...1b denote the number with k 1's. Note that
n(k)=$b^{k-1}+b^{k-2}+b^{k-3}+\cdots+1$=(bk-1)/(b-1).

We claim that when p is not a factor of b, then n(k) is a multiple of p for some k.

Use factor theorem, we know that $x^{k-1}+x^{k-2}+x^{k-3}+\cdots+1=(x-1)q(x)+k$. Consequently, n(k)=k mod (b-1). Therefore if p is a factor of b-1 (and hence not a factor of b), then p divides n(b-1).

By Fermat's little theorem, we know that if p is not a factor of b, then p divides bp-1-1. Therefore if p is neither a factor of b nor a factor of b-1, then p divides n(p-1).

The claim is proved. Please note that if n(k) is a multiple of p, then so is n(2k), n(3k), and so on.

## Wednesday, March 27, 2013

### Permutation and Group

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

A permutation of a permutation, is the product of the two permutations?
Right. The multiplication is not commutative, i.e in general abba. For example $$\begin{pmatrix}1&2&3\\1&3&2\end{pmatrix}\begin{pmatrix}1&2&3\\2&3&1\end{pmatrix}=\begin{pmatrix}1&2&3\\3&2&1\end{pmatrix}$$ but $$\begin{pmatrix}1&2&3\\2&3&1\end{pmatrix}\begin{pmatrix}1&2&3\\1&3&2\end{pmatrix}=\begin{pmatrix}1&2&3\\2&1&3\end{pmatrix}.$$
What happens if I keep permuting using the same permutation?
If you keep permuting with same permutation, you will eventually return to the initial configuration. For example $$\begin{pmatrix}1&2&3\\2&3&1\end{pmatrix}\begin{pmatrix}1&2&3\\2&3&1\end{pmatrix}\begin{pmatrix}1&2&3\\2&3&1\end{pmatrix} =\begin{pmatrix}1&2&3\\2&3&1\end{pmatrix}\begin{pmatrix}1&2&3\\3&1&2\end{pmatrix} =\begin{pmatrix}1&2&3\\1&2&3\end{pmatrix}.$$ The identity permutation, usually denoted by (1), is the permutation that changes nothing. We know that, say, there are n objects, then applying the same permutation for n! times will always end up to be the identity permuation, i.e. $$\tau^{n!}=(1)$$
Can I say τn!-1=1/τ?
Not quite. But you can write τn!-1-1, meaning that it is the multiplicative inverse of τ in the permutation multiplication.

Muliplication with an identity element and inverses. It is a group!?
Right. It is a group.
For every element α of a group G, we define a function Aα(g)=αg. It is not hard to see that Aα is a bijection and so it is a permutation. Indeed we have AαAβ=Aαβ. Hence if we identify α with Aα, we see that each element of a group is indeed a permutation of the group!

## Friday, March 22, 2013

### Permutations

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

Permutation of n objects is just a bijection on the set of these n objects?
Right.  If we don't specify the set, we means a permutation on the set {1,2,3,...,n}.

How to present a permutation?
Of course, we can present it as a bijection, e.g.
$$f(x)=\begin{cases}1 & x=1\\3 & x=2\\2 & x=3\end{cases}$$ However, traditionally we have a simpler presentation
$$\left(\begin{matrix}1&2&3\\1&3&2\end{matrix}\right)$$ which is, I believe, self-explanatory. The lower part is the new arrangement.

Why not just write (1 3 2)?
It is because we already use this symbol for a special type of permutations-the cycles. For instance (1 3 2) refers to the permutation f(1)=3, f(3)=2 and f(2)=1, i.e. $$\left(\begin{matrix}1&2&3\\3&1&2\end{matrix}\right).$$
It is easy to see cycles are interesting, mathematically?
First, we have to understand the multiplication of two permutations. If we consider two permutations $f$ and $g$ as two bijections on {1,2,3,...,n}, then their product is just the permutation $(fg)(x)=f\circ g(x)=f(g(x))$, that means if $g(r)=s$ and $f(s)=t$ then $(fg)(r)=s$. For instance, $$\left(\begin{matrix}1&2&3\\1&3&2\end{matrix}\right)\left(\begin{matrix}1&2&3\\3&1&2\end{matrix}\right)=\left(\begin{matrix}1&2&3\\2&1&3\end{matrix}\right).$$ It is known that every permutation is a product of cycles.

So cycles are the primes for permutations?
Not quite. The transpositions (i,j), i.e. the cycles of two elements, are the primes. Every permutation can be written as a product of transpositions. e.g. $$\left(\begin{matrix}1&2&3&4&5\\3&5&4&1&2\end{matrix}\right)=(1\, 3\, 4)(2\, 5)=(1\, 4)(1\, 3)(2\, 5).$$

## Thursday, March 14, 2013

### 1=0!?

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

(Growing lazy, not a good sign....)

I have seen a proof, saying that 1=0!?
Which one do you mean '"1=0!"?' or '"1=0"!?', uh?

You got the trick. Why do we use "!" for factorial?
I am not a historian, I don't know why Christian Kramp choose n! to represent factorial.

Why does 0!=1?
Lets first consider the definition of factorial. The n! is the number of ways to permute n objects. In the set theory language, n! is the size of the set of all bijective maps on a set of n elements.
Let A be a set. A bijective map or a bijection or a permutation is a subset F of A×A such that
1. For any elements a∈A, there exists a unique F(a)∈A such that (a,F(a))∈F.
2. For any elements a∈A, there exists a unique F-1(a)∈A such that (a,F-1(a)∈F.
For example the map on {x,y,z} such that F(x)=y, F(y)=z, F(z)=x is a bijection (and hence a permutation), but G(x)=y, G(y)=x, G(z)=x is not.

On {x,y,z}, we have six permutations, right?
Yes. They are
• (F(x), F(y), F(z))=(x, y, z)
• (F(x), F(y), F(z))=(x, z, y)
• (F(x), F(y), F(z))=(y, x, z)
• (F(x), F(y), F(z))=(y, z, x)
• (F(x), F(y), F(z))=(z, x, y)
• (F(x), F(y), F(z))=(z, y, x)
Hence 3!=6.

On empty set ∅, ...?
Note that ∅ equals to and is the only subset of ∅×∅. There is no way we can violate the two conditions, and so ∅ is the bijection on ∅. Therefore 0!=1.

## Thursday, March 7, 2013

### Cardinal Numbers

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

(A blog a week, keep my lazy away.... sort of)

Ordinal numbers are about order. Cardinal numbers are about quantities. In the previous post, we know what is an ordinal number. What is a cardinal number?
A cardinal number is a set of sets such that whenever we pick two sets in it, we can pair up their elements.  If two sets lie inside the same cardinal number, we say that they are of the same cardinality.
For example,  {a,b,c} and {x,y,z} are of the same cardinality, as we can pair up their elements as (a,x), (b,y) and (c,z).

A natural number is a cardinal number. Isn't it?
Well, we use a natural number as the representative of its cardinal number.
For example, {a,b,c} and 3={0,1,2} are of the same cardinality, and so we say that {a,b,c} has 3 elements.

So, if the elements of a set can be labelled as 0,1,2,...,n-1, then the set has n elements. Right?
Exactly.  It is just our usual sense of numbers. However, we are used to label the elements with 1,2,3,...,n instead.

The first infinite cardinal number is still ω={0,1,2,3,...} ?
Yeah.  Unlike ordinal numbers, 1+ω=ω=ω+1.
The sum of cardinal numbers are defined by, #A+#B=#(A×{0} ∪ B×{1}).
For example, 3+4=#{a,b,c}+#{x,y,z,w}=#{(a,0),(b,0),(c,0),(x,1),(y,1),(z,1),(w,1)}=7.

So, m+n=n+m?
Right. It is easy to see that A×{0} ∪ B×{1} and A×{1} ∪ B×{0} should have the same cardinality.

I guess the product of two cardinal numbers is (#A)(#B)=#(A×B)?
Good. For example
3×4
=(#{a,b,c})(#{x,y,z,w})
=#{(a,x),(a,y),(a,z),(a,w),(b,x),(b,y),(b,z),(b,w),(c,x),(c,y),(c,z),(c,w)}
=12.
Again, we have m×n=n×m.

## Tuesday, February 26, 2013

### Ordinal numbers.

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

Giuseppe Peano says 1 is the smallest natural number, while John von Neumann says that 0 is the smallest natural number?
Yes. In the past, or even nowadays, 0 as a number is not quite natural in many people's eyes. However, when mathematicians want to give a vigorous definition for ordinal numbers, they figure out that 0 should be the starting point.

What is the vigorous definition for ordinal numbers?
An ordinal number α is a set of ordinal numbers that are smaller then α.

So 3={0,1,2}, 5={0,1,2,3,4} are ordinal numbers?
True. All natural numbers are ordinal numbers. Indeed the set

ω={0,1,2,3,...}
is also an ordinal number. It is the smallest infinite ordinal number.

The second smallest infinite ordinal is {0,1,2,...,ω}?
Yes, it is ω+1. Note that it is different from 1+ω which equals to ω. The definition of addition is like this--
{0,1,2,...}+{0,1,2,...}={0,1,2,..., 0,1,2,...},
where the symbols with different colors are considered different, and that the elements are listed in the order.
By renaming the elements, we see that
3+2={0,1,2}+{0,1}={0,1,2}+{3,4}={0,1,2,3,4}=5.
The addition for finite ordinals is the usual addition of natural numbers.
However, we see that
ω+1={0,1,2,...}+{0}={0,1,2,...}+{ω}={0,1,2,...,ω} but
1+ω={0}+{0,1,2,3,...}={0}+{1,2,3,...}=ω.
The two are different as ω+1 has a largest element but ω does not.

I doubt we still ignore 0 with we deal with ordinal numbers in daily language?
Well, we have invented a word "zeroth", denote that something should come earlier before the first object in a series. For example, the zeroth chapter or the zeroth law of thermodynamics.

## Monday, February 18, 2013

### 3={0,1,2}

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

In the last post, we mentioned that sometimes we identify 2={0,1}. So 3={0,1,2}, 4={0,1,2,3}?
Yes. It is the construction of natural numbers by polymath John von Neumann:
• 0={ }, the empty set.
• n+1=n∪{n}.
Therefore we have: 0={ }, 1={0}, 2={0,1}, 3={0,1,2}, .... In general n={0,1,2,...,n-1} for n≥1.

I see, so n is a set of n elements, right?
1. n is a set of n elements.
2. The definition is recursive, it does not depend on anything outside the number system.
3. n> m if and only if n is an element of m.
4. nm if and only if n is a subset of m.
5. This definition can be extended to infinite ordinals.

Are there any other definitions for natural numbers?
Yes. For instance, 0={ }, 1={0}, 2={1}, etc. As soon as the definition fits Peano axioms, that's okay.

What are Peano axioms?
Proposed by Giuseppe Peano, there are five axioms:
1. There is an initial number, called 0. (Peano indeed use 1 as the initial number)
2. There is a successor operation. If n is a natural number, its successor is denoted by n+1.
3. For all nonzero natural number m, there exists a unique n such that n+1=m.
4. There exists no natural number n such that n+1=0.
5. If 0 has Property P and that "if n has Property P then n+1 also have Property P", then all natural numbers have Property P.

The last property is the mathematical induction?
Well... the reason that mathematical induction works is that it is a property of the natural number system!

## Tuesday, February 12, 2013

### The power set of X

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

Suppose X and Y are sets. What is YX?
YX is the set of all functions from X to Y. From the last post, we see that if X has n elements and Y has m elements, then YX has mn elements.

What is 2X?
If we write like that, we identify 2 with a set with two elements, in particular we can consider 2={0,1}. Therefore 2X is simply a set of functions that for each x∈X, f(x) takes up values as 0 or 1.

How do we describe a function in 2X?
Since f(x) can only have two values, we can describe the function f using the preimage of 0, i.e. f-1(0)={x∈X   :   f(x)=0}. In other words, each function in 2X corresponds to exactly one subset of X.

2X is sometimes used to denote the power set of X, right?
A power set of X, usually denoted by P(X), is the set of all subsets of X. Because there exists a correspondence between the functions in 2X and the subsets in P(X), so we sometimes really consider them identical.
For example, if X={a,b,c}, then P(X)={∅, {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c}} and the eight functions in 2X are
f(a)=f(b)=f(c)=1;
f(a)=0, f(b)=f(c)=1;
f(b)=0, f(a)=f(c)=1;
f(c)=0, f(a)=f(b)=1;
f(a)=f(b)=0, f(c)=1;
f(a)=f(c)=0, f(b)=1;
f(b)=f(c)=0, f(a)=1;
f(a)=f(b)=f(c)=0.

## Sunday, February 10, 2013

### ∅∅={∅}

If you are in Hong Kong and you need help for university mathematics courses, please visit  www.all-r-math.com.

Suppose X and Y are sets. What is YX?
YX is the set of all functions from X to Y.

What is a function from X to Y?
According to the modern definition, f is a function from X to Y is simply a subset of X×Y satisfying
• Every element xX associates with a unique element f(x) in Y.
Put it in another way, a subset f of X×Y is a function if
1. No element xX associates with nothing in Y, i.e. f(x) always exists and
2. No element xX associates with two or more elements in Y, i.e. there cannot be two f(x).

Examples:
1. f(x)=a square root of x is a function from [0,∞) to [0, ∞).
2. f(x)=a square root of x is not a function from (-∞,∞) to [0, ∞) because there is no f(-1).
3. f(x)=a square root of x is not a function from [0,∞) to (-∞, ∞) because there are two f(1), i.e. 1 and -1.

If M is a set with m elements and N is a set with n elements (m,n≠0), then what is the size of MN?
Easy. MN has exactly mn.
For instance, let M={0,1,2} and N={0,1}, then MN contains the following 32=9 elements:
f(0)=f(1)=0;
f(0)=0, f(1)=1;
f(0)=0, f(1)=2;
f(0)=1, f(1)=0;
f(0)=f(1)=1;
f(0)=1, f(1)=2;
f(0)=2, f(1)=0;
f(0)=2, f(1)=1;
f(0)=f(1)=2
.

What is ∅X if X≠∅?
X=∅.
Take any element x of X, we see that it can associate with nothing! Therefore no function exists. Note that it matches with our common notation that 0n=0 if n≠0.

What is Y if Y≠∅?
Y={∅}, the set which contains the empty set as its unique element!!!
∅=∅×Y is itself a function from ∅ to Y, why? Because there is no element in an empty set, hence (1) no elements in an empty set will corresponds to no elements and (2) no elements in an empty set will corresponds to two or more elements. Weird!! Counting the number of elements, we see that it matches our common notation that m0=1 if m≠0.

What is ∅?
Using exactly the same argument as before, we know that ∅={∅}.
Counting the number of elements, we have 00=1! This equality is true only if we consider 0 as a counting number.

## Tuesday, February 5, 2013

### Baye's formula

If you are in Hong Kong and you need help for university mathematics courses, please visit www.all-r-math.com.

[Quite lazy recently, so write harder..... :( ]

A friend just asks me what is Baye's formula.

The simplest form is

P(A|B)P(B)=P(B|A)P(A)

where P(A|B) means the conditional probability of A given that B happens.

Lets we take a frequentist approach. Suppose out of N trials, A appears a times, B appears b times, and in c trials, both A and B occur. Then

P(A|B)=c/b=(c/N)/(b/N)=P(A and B)/P(B)

and therefore

P(A|B)P(B)=P(A and B).

Likewise P(B|A)P(A)=P(A and B). Hence we deduce the Baye's formula.

Example: We throw a dice. Let A={1,2}, B={1,3,5}, C={2,3,5}.

P(A)=1/3, P(B)=P(C)=1/2, P(A and B)=P({1})=1/6, P(A and C)=1/6, P(B and C)=1/3.

P(A|B)=1/3, P(A|C)=1/3.

P(B|A)=1/2, P(B|C)=2/3.

P(C|A)=1/2, P(C|B)=2/3.

We say that two events X and Y are independent if P(X and Y)=P(X)P(Y). If P(Y)≠0 it is the same as saying that P(X|Y)=P(X).

Now we see that B and C are not independent.  However we have A and B are independent, and that A and C are also independent.  Not the same kind of independence in our usual sense, right?

## Thursday, January 17, 2013

### Answer to the previous blog

If you are in Hong Kong and you need help for university mathematics courses, please visit www.all-r-math.com.

Suppose there are n lightbulbs, k of them have defects. A technician is allowed to check m lightbulbs and it turns out that exactly l defected ones among those checked.
1. Given n,k,m,l, what is the probability mass function (PMF) for l? What is the expected value?
2. Given n,m,l, what is the probability mass function (PMF) for k? What is the expected value?
(Sorry that I have to change the notations, so the presentation is clearer.)
1. Probability is (number of particular outcomes)/(number of all possible outcomes).
• k≥n: In this case 0≤l≤m. The total number of ways for choosing m bulbs from the n bulbs is $C_m^n$. Number of ways that there are l defected bulbs among m chosen bulbs equals $C_l^kC_{m-l}^{n-K}$. Therefore the conditional probability for $L=l$ given $K=k$ is $$P(L=l|K=k)=\frac{C_l^kC_{m-l}^{n-k}}{C_m^n}.$$ Interestingly, rearranging the terms, we have (what does it mean?) $$P(L=l|K=k)=\frac{C_l^mC_{k-l}^{n-m}}{C_k^n}$$ The expected value equals the sum of (outcome × probability). Therefore $$E[L|K=k]=\sum_{k=0}^m\frac{lC_l^kC_{m-l}^{n-k}}{C_m^n}.$$
• k≤n: In this case 0≤l≤k. Again $$P(L=l|K=k)=\frac{C_l^kC_{m-l}^{n-k}}{C_m^n}.$$ The expected value is $$E[L|K=k]=\sum_{k=0}^k\frac{lC_l^kC_{m-l}^{n-k}}{C_m^n}.$$
2. Indeed there is something missing in the question: How is k distributed? Lets assume that it is K~Bin(N,p), that is, each bulb has a probability p to be defected and that $P(K=k)=C_k^np^k(1-p)^{n-k}$. Therefore $$P(K=k|L=l)=\frac{P(Y=K, L=l)}{P(L=l)} =\frac{P(K=k)P(L=l|K=l)}{\sum_{k=l}^nP(K=k)P(L=l|K=k)}$$ and $$E[K|L=1]=\frac{kP(K=k)P(L=l|K=l)}{\sum_{k=l}^nP(K=k)P(L=l|K=k)}.$$

The second question:
Suppose there are n lightbulbs, k of them have defects. A technician is allowed to check m lightbulbs. What is the probability that he can find out all the defected?

Answer: The technician can find all the defected bulbs if either all the defected bulbs or all the normal bulbs are among those checked. Therefore the answer is $$P(\mbox{he finds all})=\begin{cases} \frac{C_{m-k}^{n-k}}{C_m^n} & n-k>m>k \\ \frac{C_{m-k}^{n-k}+C_{m-(n-k)}^k}{C_m^n}& m\ge n-k,k \\ \frac{C_{m-(n-k)}^k}{C_m^n} & k>m>n-k \end{cases}$$

## Tuesday, January 15, 2013

### A probability question

If you are in Hong Kong and you need help for university mathematics courses, please visit www.all-r-math.com.

Suppose there are N lightbulbs, K of them have defects. A technician is allowed to check n lightbulbs and it turns out that exactly k defected ones among those checked.
1. Given N,K,n, what is the probability mass function (PMF) for k? What is the expected value?
2. Given N,n,k, what is the probability mass function (PMF) for K? What is the expected value?

A somewhat similar question is:
Suppose there are N lightbulbs, K of them have defects. A technician is allowed to check n lightbulbs. What is the probability that he can find out all the defected?

## Monday, January 7, 2013

### Subtraction of Numbers

If you are in Hong Kong and you need help for university mathematics courses, please visit www.all-r-math.com.

Many many years ago, when I first encountered the computer algorithm for subtraction of numbers, I really do not know what happens.
Several days ago, I have read an article saying that the primary school kids, who are okay to do additions, face difficulties in subtractions.
The two problems seems unrelated, but they are really the same problem.
Addition is easy, subtraction is hard, for computers and kids alike!

Lets review how a computer do base 2 addition:

To add two numbers, with fixed length, say (01001101)+(00011101). We need three memory units: N1 to hold a digit for the first number, N2 to hold a digit for the second number, C to hold a carry digit.

Step 1. Load the last digit of the first number to N1, the last digit of the second number to N2, 0 to C. Then do the following operation:
 N1 N2 C Result Digit and new C 0 0 0 0, 0 0 0 1 1, 0 0 1 0 1, 0 0 1 1 0, 1 1 0 0 1, 0 1 0 1 0, 1 1 1 0 0, 1 1 1 1 1, 1
(Basically, it means N1+N2+C=(new C, Result Digit).)
In our example, N1=1, N2=1, C=0, so the result is 0 and new C=1.

Step 2. Load the next digit (on the left side) of the first number to N1, the next digit of the second number to N2. Again follow the table above.
In our example, N1=0, N2=0, C=1, so the result is 1 and new C=0.

Step 3-Step 8. Repeat Step 2.
In our example, it is
• N1=1, N2=1, C=1: result is 0, new C=1
• N1=1, N2=1, C=1: result is 1, new C=1
• N1=0, N2=1, C=1: result is 0, new C=1
• N1=0, N2=0, C=1: result is 1, new C=0
• N1=1, N2=0, C=0: result is 1, new C=0
• N1=0, N2=0, C=0: result is 0, new C=0

Looks fancy, but it is just how we do addition. Now, for subtraction.

Lets use the same two numbers: (01001101)-(00011101).

Step 1. Change the second number, switch 0 and 1, so it becomes (11100010).

Add the first number and the new second number: (010001101)+(11100010)=(00101111).

Why does it work?
Because we are not doing really the usual addition and subtration, we are doing modulo arithmetic!!!

We say that m=n (mod R) is m-n is divisible by R. If we are doing arithmetic under this equivalence relation, we are doing modulo R arithmetic, or ZR-operations.
For example, in modulo 3 arithmatic, we have
 + 0 1 2 0 0 1 2 1 1 2 0 2 2 0 1
 × 0 1 2 0 0 0 0 1 0 1 2 2 0 2 1
The computer arithmetic is simply doing modulo 28 arithmetic. Therefore
(01001101)-(00011101)
=(001001101)-(000011101)
=(001001101)-(000011101)+(100000000)
=(001001101)-(000011101)+(011111111)+(000000001)
=(001001101)+(011100010)+(000000001)
=(01001101)+(11100010)+(00000001)

It explains the algorithm.

Now I wish to propose a new subtraction algorithm for kids, using the same idea.

Say, we want 19021-8742.

Rewrite the second number as 08742, then switch using 0<->9, 1<->8, 2<->7, 3<->6, 4<->5. The new number is 91257

Add the first number and the new number, ignore the leftmost digit: 19021+91257=10278.