As of May 4 2007 the scripts will autodetect your timezone settings. Nothing here has to be changed, but there are a few things

Please follow this blog

Search this blog

Showing posts with label Combinatorics. Show all posts
Showing posts with label Combinatorics. Show all posts

Saturday, March 10, 2012

Exxercise in counting

Given 5 children and 8 adults, how many ways can they be seated so that there are no two children sitting next to each other. ( From math.stackexchange )

I haven't opened the question yet. I got alerted by this question that my discrete mathematics skills are getting -sloppy-! It happened to me before. There was a time when I thought that I had forgotten all of my linear algebra skills. I can assure you that going through all that material again feels overwhelming. Counting is an essential skill I am going through it again. The theory won't be the problem. I know the formulas, it's the skill in which theorems to apply to a certain to problem, or how to model a counting problem. Boxes or balls? Repetition, yes or no? Distinct or similar objects? Should I use the addition or product rule?

As elementary number theory, enumerative combinatorics ( = counting ) is part of the Olympiad curriculum, so there are TONS of practice questions 'out-there' (*).


(*) Anywhere from Amazon to IRC #bookz channels to the shadow-Internet. What suits you (r budget ) best. As long as you are learning.

Tuesday, April 19, 2011

Magic squares of type n-by-n

I wrote a small program that can generate a magic square for any size of a matrix. The idea is that this program can support me in my quest to generate some particular normal magic squares. The ideas I got thus far were too computationally intensive though. It remains an interesting enough playground for me, a challenging enough problem that I might solve one day. - I have read that you need some sort of portfolio of problems on which you can work alternately depending on how you feel, think, etc. on a given moment.

$$
\left(
\begin{array}{ccc}
9 & 6 & 3 \\
0 & 6 & 12 \\
9 & 6 & 3
\end{array}
\right)
$$
$$
\left(
\begin{array}{cccc}
9 & 6 & -1 & -4 \\
5 & -6 & 3 & 8 \\
-8 & 7 & 6 & 5 \\
4 & 3 & 2 & 1
\end{array}
\right)
$$
$$
\left(
\begin{array}{ccccc}
40 & 30 & -46 & 8 & -2 \\
40 & -43 & 30 & -11 & 14 \\
-52 & 26 & 24 & 22 & 10 \\
-8 & 9 & 16 & 7 & 6 \\
10 & 8 & 6 & 4 & 2
\end{array}
\right)
$$
$$
\left(
\begin{array}{cccccc}
165 & 118 & -86 & -79 & -59 & -38 \\
84 & -187 & 48 & 46 & 8 & 22 \\
-113 & 42 & 20 & 19 & 36 & 17 \\
-78 & 32 & 15 & 14 & 26 & 12 \\
-43 & 11 & 20 & 18 & 8 & 7 \\
6 & 5 & 4 & 3 & 2 & 1
\end{array}
\right)
$$
$$
\left(
\begin{array}{ccccccc}
344 & 272 & -144 & -180 & -124 & -66 & -46 \\
228 & -391 & 70 & 68 & 66 & -17 & 32 \\
-202 & 62 & 30 & 58 & 28 & 54 & 26 \\
-194 & 50 & 48 & 46 & 44 & 42 & 20 \\
-94 & 38 & 18 & 34 & 16 & 30 & 14 \\
-40 & 13 & 24 & 22 & 20 & 9 & 8 \\
14 & 12 & 10 & 8 & 6 & 4 & 2
\end{array}
\right)
$$
$$
\left(
\begin{array}{cccccccc}
795 & 644 & -283 & -272 & -261 & -250 & -213 & -124 \\
493 & -890 & 96 & 94 & 92 & 90 & 17 & 44 \\
-406 & 86 & 42 & 82 & 80 & 39 & 76 & 37 \\
-329 & 72 & 70 & 34 & 33 & 64 & 62 & 30 \\
-252 & 58 & 56 & 27 & 26 & 50 & 48 & 23 \\
-175 & 44 & 21 & 40 & 38 & 18 & 34 & 16 \\
-98 & 15 & 28 & 26 & 24 & 22 & 10 & 9 \\
8 & 7 & 6 & 5 & 4 & 3 & 2 & 1
\end{array}
\right)
$$

Magic squares of type 5-by-5

Still in 're-discovery mode' generating magic squares has become trivial, although the computational resources increase fast depending on the size of the square.
$$\left(
\begin{array}{ccccc}
14 & 32 & 6 & 8 & 22 \\
14 & 7 & 30 & 17 & 14 \\
0 & 26 & 24 & 22 & 10 \\
44 & 9 & 16 & 7 & 6 \\
10 & 8 & 6 & 28 & 30
\end{array}
\right)$$
$$\left(
\begin{array}{ccccc}
4 & 22 & 6 & 28 & 42 \\
4 & 37 & 30 & 17 & 14 \\
20 & 26 & 24 & 22 & 10 \\
64 & 9 & 16 & 7 & 6 \\
10 & 8 & 26 & 28 & 30
\end{array}
\right)$$
$$\left(
\begin{array}{ccccc}
4 & 6 & 22 & 26 & 64 \\
6 & 55 & 30 & 17 & 14 \\
16 & 34 & 24 & 42 & 6 \\
86 & 7 & 16 & 7 & 6 \\
10 & 20 & 30 & 30 & 32
\end{array}
\right)$$

About definitions.

Magic square
A magic square is a square matrix with elements in $\mathbf{Z}$ such that the totals of rows, columns and both diagonals are equal.
Normal magic square
A normal magic square is a magic square with elements $1,2, \cdots, n^2$ where $n$ is the size of the matrix.
Latin square
A latin square is a $n$ by $n$ square matrix containing $n$ times the first $n$ elements of the alphabet such that each row and each column contains each letter only once. (i.e. Cayley Table)

Further developments

Clearly, normal magic squares are the most desirable objects in the realm of matrices. I am making detailed notes about this work in the ( still? ) unpublished personal mathematics wiki I am setting up.

Saturday, April 9, 2011

Ramanujan's magic square formula - Revisited

Ramanujan's genius (r) was discovered by Hardy (l)
At a very young age Ramanujan designed the following formula for a 3 by 3 magic square:

C+Q | A+P | B+R
A+R | B+Q | C+P
B+P | C+R | A+Q

where A,B,C are integers in arithmetic progression and so are P,Q,R.


Rewriting Ramanujan's scheme somewhat to
2Q+R | 2P+2R | P+Q
2P | P+Q+R | 2Q+2R
P+Q+2R | 2Q | 2P+R

where P,Q,R are in the Rationals, it is clear that every (P,Q,R) yields a magic square with constant number 3 (P + Q + R).

I conjecture that for any 3 by 3 magic square a triple (P,Q,R) can be found in the Rationals such that they fit the above scheme. Finding a proof for this is one of my 'problems'. Naturally, I would be very interested in any counter-example.

Friday, April 8, 2011

Decomposition of the magic square on Drurer's Melancholia

Durer's Melancholia

Durer's Melancholia is world famous for its magic square on the top right wall.

16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1

It is a real magic square because it contains the integers 1,2, ..., 16 on 4x4 places. The constant of this magic square is 34. I have been thinking if there are any 'beautiful' ways in decomposing it into two or more (magical) squares. Best I have come up sofar are two squares with constant number 17.

1 3 1 12
3 10 0 4
9 1 6 1
4 3 10 0

15 0 1 1
2 0 11 4
0 5 1 11
0 12 4 1

Add them and the result is Drurer's magic square.

Thursday, March 31, 2011

Generating 4 x 4 magic squares ( 2 ) - ( MathCad = MathCrap )

To be precise, my squares would have been magic if I would have only used the numbers 1 to 16 once each. Like in this famous magic square found in 'Melancholia' by Albrecht Dürer.
16 -  3 -  2 - 13
 5 - 10 - 11 -  8
 9 -  6 -  7 - 12
 4 - 15 - 14 -  1 

I am trying to find the parameters required by my method to generate this one. As a test.

I am not sure if this is just procrastination or that this qualifies as 'real mathematics'. I suppose it depends on the result and how I document it. Positive side-effects are that I am now much more interested in M373 and that I am still getting better in Mathematica. - Mathematica can be used as a super calculator of course, but I am beginning to use it as a tool to actually do some 'thinking-work' for me.

Am I still studying for B31? Of course!

Well, M373 entered -Yellow Alert- phase. A plus of M373 is that the topics are really, really interesting. But, I don't like MathCad. It is such a honky tonky load of crap, unbelievable. And then we get the 2001 version! I use the latest version, of course, crapwise certainly an improvement over 2001. - The Open University obviously wasn't by their right mind when they chose PTC ( the manufacturers of MathCad ). Perhaps they had no choice because PTC is the only supplier of mathematics software based on British soil. And Maple ( which seems to be almost as good as Mathematica ) courses are being dropped. Students do have limits as to what they will accept though.

Just about to ship a M381 TMA.

Wednesday, March 30, 2011

Generating 4 x 4 magic squares

Inspired by Ramanujan, I am playing, experimenting, with 4 x 4 magic squares. I have ( independently ) found a way to generate them, infinite many of them if necessary. What's interesting about it is that theoretically the method should work for n x n magic squares.

15 0 9 8
5 5 4 18
5 13 10 4
7 14 9 2

15 10 10 7
6 13 5 18
4 13 11 14
17 6 16 3

16 106 160 79
156 85 6 114
1 88 182 90
188 82 13 78

Two follow-up projects come to mind. 1) A reading experiment. Since I discovered part about mathematics independently ( thanks to Ramanujan's 3 x 3 formula, of course ) reading about this topic in the literature should be quite different compared to reading about a subject you know nothing about, i.e. when the reading-protocol is 'discovery'. Anyway, that is the experiment. 2) A writing experiment. I'll try to write down the method I use with as much rigor as I possibly can. Will I be able to produce something readable? - Unfortunately I have more urgent tasks to handle.

Monday, May 3, 2010

Generating functions

See how multiplication with $\frac{1}{x}$ summates the sequence upto n.
$
\begin{matrix}
\text{sequence} & \text{generating function} & \text{formula}\\
1,1,1, \cdots & \frac{1}{1-x} & f(n)=1\\
1,2,3, \cdots & \frac{x}{(1-x)^2} & f(n)=n\\
1,3,6, \cdots & \frac{x}{(1-x)^3} & f(n)=\frac{n(n+1)}{2}\\
1,4,10, \cdots & \frac{x}{(1-x)^4} & f(n)=C(n+3,n)
\end{matrix}
$

Saturday, May 1, 2010

Pascal Triangle - Ordered k-partitions

The number of integer solutions to
x1 + x2 + x3 = 6
with x1,x2,x3 >= 1 is equal to the number of integer solutions to
x1 + x2 + x3 = 3
with x1,x2,x3 >=0.
It is like distributing three similar balls into three different buckets, solutions are:
b b b | | ( x1=3, x2=0, x3=0 )
b b | b | ( x1=2, x2=1, x3=0 ).
A pattern appears. We are in fact looking at the number of different arrangements of three b's and 2 |'s, which is ( 3 + 2 )! / 3! 2! = C(5,2) = 10.
Let's list the solutions anyway.
3 - 0 - 0
2 - 1 - 0
2 - 0 - 1
1 - 2 - 0
1 - 1 - 1
1 - 0 - 2
0 - 3 - 0
0 - 2 - 1
0 - 1 - 2
0 - 0 - 3
or translated to the original question:

4 - 1 - 1
3 - 2 - 1
3 - 1 - 2
2 - 3 - 1
2 - 2 - 2
2 - 1 - 3
1 - 4 - 1
1 - 3 - 2
1 - 2 - 3
1 - 1 - 4.
They are in fact all the ordered 3-partitions of 6.
So we can interpret C(n,k) as the ordered (k+1)-partitions of (n+1).

Pascal Triangle

I suppose we can all dream the Pascal Triangle.
1
1-1
1-2-1
1-3-3-1
1-4-6-4-1
1-5-10-10-5-1
1-6-15-20-15-6-1
etc.
Until today I did not know that we could simply read the following sum from the triangle.
$$ s(n) = \sum_{i=1}^{n} i \cdot ( n-i ) $$
Like for example 100 * 1 + 100 * 2 + 100 * 3 + 100 * 4 + ... + 1 * 100 = ? The answer is in the triangle. Amazing. Or perhaps "fascinating" is a better word.

Fixed-point-free permutations

The permuations of the elements of {1,2,3} are followed by the permutioncycle(s)
1-2-3 = (1)(2)(3)
1-3-2 = (1)(23)
2-1-3 = (12)(3)
2-3-1 = (123)
3-1-2 = (132)
3-2-1 = (13)(2).
Only two of them are so called "fixed-point-free", i.e. they have no cycles of length 1: 2-3-1 and 3-1-2. There is a symbol for this number D for derangement. So D(3)=2. We can easily find D(4) by thinking in permutation cycles: those that do not include length 1 cycles are fixed-point-free. The possible cycle structures of permutations of length 4 are 1-to-1 related to the partitions of 4 ( number of permutations ).
4 = xxxx ( 6 = 4*3*2*1 / 4 )
31= xxx-x ( 8 = 4*3*2 / 3 )
22 = xx-xx ( 3 = 4*3 / 2 * 2 )
211 = xx-x-x ( 6 = 4*3 /2)
1111 = x-x-x-x ( 1 = 1 )
All basic M208/GTA1 material, I suppose. This formula is however not in the course.
$$D(n) = n! \cdot \sum_{k=0}^{n} \frac{(-1)^k}{k!}$$
With the formula for D we can simply check the result for 4.
$$D(4) = 4! \cdot (
\frac{(-1)^0}{0!} +
\frac{(-1)^1}{1!} +
\frac{(-1)^2}{2!} +
\frac{(-1)^3}{3!} +
\frac{(-1)^4}{4!} ) =9.
$$

Wednesday, April 28, 2010

Generating Functions

I am revising what I have learned on generating functions. GFs are extremely cool and powerful, they are among the mathematical objects I love most.

The sequence {1,3,9,27,81,243,...} has an equivalent GF 1 / ( 1-3x).

Something else, I have this strong desire to work on a real problem, to work on mathematics of my own. But it is too early there is still so much I can pick up from courses and the literature.

Sunday, April 25, 2010

Bell Number

$$B(n) = \sum_{k=0}^{n} S(n,k) $$

with the first five Bell numbers :
$\begin{array}{llllll}
&&&&&Total\\
1 &&&&&1 \\
0 & 1 &&&&1\\
0 & 1 & 1 & &&2\\
0 & 1 & 3 & 1 & &5\\
0 & 1 & 7 & 6 & 1&15
\end{array}$

A beautiful recurrence formula for the Bell number is
$$B(n) = \sum_{k=0}^{n-1} B(k) \cdot C(n-1,k) ,$$
for example for n=4 we get: 1* 1+ 1*3 + 2*3 + 5*1 = 15.

I now have the sixth edition of the book Discrete Mathematics and Its Applications by Kenneth Rosen.

A great book which comes with the best accompanying student website I have seen sofar for a mathematics book. It probably takes hours to just to browse through all the applets.

Saturday, April 24, 2010

Stirling numbers of the first kind

$
\begin{array}{lllll}
1 &&&&\\
0 & 1 &&&\\
0 & 1 & 1 &&\\
0 & 2 & 3 & 1 &\\
0 & 6 & 11 & 6 & 1
\end{array}
$
A stirling number of the first kind is the number of permutations of {1, 2, ..., n } with k permutation cycles. Take for example the permutations of {1,2,3 }:
123 - (1)(2)(3)
132 - (1)(23)
213 - (12)(3)
231 - (132)
312 - (132)
321 - (13)(2)
each line consists of the same permutation but in different notation. After the - I noted the permutation in cycle notation. So there are 2 3-permutations of 1 cycle, 3 of 2 cycles and 1 of 3 cycles.

Friday, April 23, 2010

Stirling numbers of the second kind - continued

As we can deduce from the recurrence
 $$C(n,k) = C(n-1,k-1) + C(n-1,k)$$ that
$$C(n,k) = \frac{1}{k!} \prod_{j=0}^{k-1}(n-j),$$
where $C(n,k)$ is the number of k-subsets out of an n-set, we can similarly find a closed form for the recurrence $$S(n,k) = S(n-1,k-1) + k \cdot S(n-1,k)$$ which is
$$S(n,k) = \frac{1}{k!} \sum_{j=0}^{k} (-1)^{k-j} j^n C(k,j) ,$$ where $S(n,k)$ is the number of k-partitions of an n-set, a Stirling number of the second kind.

The tech for doing discrete sums is really spectaculair imho and therefore want to know much more about it.

Tuesday, April 20, 2010

Stirling numbers of the second kind

( Repeat / memorized ) from Aigner, A course in enumeration.

Stirling numbers of the second kind: S(n,k).
Definition. S(n,k) is the number of k-partitions of an n-set.

Example:
{A}
S(1,1)=1
A

{A,B}
S(2,1)=1
AB
S(2,2)=1
A-B

{A,B,C}
S(3,1)=1
ABC
S(3,2)=3
A-BC
B-AC
C-AB
S(3,3)=1
A-B-C

Almost similar as for the number of combinations ( C(n,k)= C(n-1,k-1) + C(n-1,k) ) we can define the Stirling numbers of the second kind recursively:
S(n,k) = S(n-1,k-1) + k * S(n-1,k).
This recursion is easy to understand as we will see when we continue with the examples for {A,B,C,D}.

/* To be continued */

Wednesday, April 29, 2009

Ordered partitions

Example. The partitions of 5 are:
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1

The -ordered- partitions of 5 are:
5
4 1
1 4
3 2
2 3
3 1 1
1 3 1
1 1 3
2 2 1
2 1 2
1 2 2
2 1 1 1
1 2 1 1
1 1 2 1
1 1 1 2
1 1 1 1 1

Note:
1 ( of 1 ) = C(4,0)
4 ( of 2 ) = C(4,1)
6 ( of 3 ) = C(4,2)
4 ( of 4 ) = C(4,3)
1 ( of 5 ) = C(4,4)

The number of ordered partitions of n = 2^(n-1). In the case of 5: 2^4=16.

Try 3,4 or 6 as an ( interesting ) exercise.

Sunday, March 29, 2009

The euphoria of solving a mathematics exercise.

The first part of exercise 1.10 in 'A Course in Enumeration' by Martin Aigner asks to evaluate the sum below by counting configurations of dots.
Although the answer can be simply taken from Pascal's Triangle as
C(n+1,2)+2C(n+1,3)
the challenge of the exercise was to deduce the same answer by setting up a particular configuration of dots.

To make a long story short... that's how I spent my entire free Saturday. By not finding the answer that is. I did this ( Sunday ) morning though with great relief. I was close right away but I -sort of- forgot to finish it correctly, instead I kept searching for other, better dot configurations. In the rush of having solved another 'difficult' exercise I remembered an article with the title 'Addicted To Knowledge' which explains the feeling I had.

Aigner says in the preface: 'It is commonplace to stress the importance of exercises. To learn enumerative combinatorics one simply must do as many exercises as possible.' An exercise is only an exercise if it was a challenging exercise, I would like to add. And harder means deeper in the context of exercises.

Hint to the answer: find a dot-configuration for the sum of 1,2,3,...,n first.

Friday, November 16, 2007

Another identity in Pascal's Triangle

On the Pascal Triangle resources website I found, among many other identities, the following two basic identities:

The first one is in every book on discrete math I have seen thus far. And although basic I don't recall to have seen the second identity somewhere else so for me it is a new one.

Tuesday, November 6, 2007

Property of the Pascal Triangle

Another interesting property of the Pascal Triangle.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1

Since Choose(n,k) = (k+1)/(n-k)*Choose(n,k+1) we get ( for example ) for row 7:
1/7 * 7 = 1
2/6 * 21 = 7
3/5 * 35 = 21
4/4 * 35 = 35
5/3 * 21 = 35
6/2 * 7 = 21
7/1 * 1 = 7

Popular Posts

Welcome to The Bridge

Mathematics: is it the fabric of MEST?
This is my voyage
My continuous mission
To uncover hidden structures
To create new theorems and proofs
To boldly go where no man has gone before




(Raumpatrouille – Die phantastischen Abenteuer des Raumschiffes Orion, colloquially aka Raumpatrouille Orion was the first German science fiction television series. Its seven episodes were broadcast by ARD beginning September 17, 1966. The series has since acquired cult status in Germany. Broadcast six years before Star Trek first aired in West Germany (in 1972), it became a huge success.)