Posts Tagged ‘teaching’

Sage (sagemath.org) at GSoC 2012

19 March, 2012

Sage (not the accounting software, but sagemath.org) is accepted to Google Summer of Code 2012, and I will be one of many mentors. 

Experimental Sage-based Mathematics course

7 August, 2011

We are to embark upon teaching a 2nd year undergraduate course Experimental Mathematics, which will cover computer algebra basics, and refresh concepts from 1st year linear algebra, calculus, and combinatoris, with few more advanced things thrown in. The course will be based on Sage, with the actual software running on dedicated servers, and accessible via Sage web notebook interface (i.e. basically nothing but a web browser running on the student’s computer/laptop/ipad, etc).

Given the enrollment of about 120, this will be interesting…

PS. Most students did not appreciate the freedom given, and complained, complained, complained…

Is C++ the worst 1st programming language for maths majors?

7 May, 2010

In our department we have a 1-semester course called “Introduction to scientific programming”, that is taught to the 1st year undergrads. It is C++-based. I am arguing for years that it is a real waste, and only good for getting people dazed and confused, and that instead something like Python should be used.

The choice of Python is basically due to it being interpreted, (largely) untyped, and higher level than C/C++.
(And last but not least, free, unlike Maple, Matlab, and Mathematica, which might be marginally more useful to a maths major).

Here is a ranking of programming languages in industry. Inevitably biased in some ways, I suppose it still demonstrates that claimed “superiority” of C++ is nowhere to be seen…

Bipartite matchings via linear programming

14 September, 2009

An important tool for combinatorial optimisation problems, and graph problems among them, is linear programming, a method (and a problem) to find the optimum of a linear function on a polyhedron (i.e. on an intersection of half-spaces.) Often, such an intersection is bounded, and then one talks about a (convex) polytope rather than a polyhedron.
The optimum of a linear function on a polytope P is always reached on a vertex, or, more generally, on a set of vertices of P generating an optimal face. (A vertex is a point in P that cannot be written as a nontrivial convex combination of two other points of P.)

Here we demonstrate a way to encode the problem of finding the size of a maximum matching (or, more generally, the maximum weight of a matching) in a bipartite graph \Gamma=(V,E) as a linear programming problem.

As a warmup, we treat perfect matchings. Consider the vector of |E| variables x=(x_{e_1},x_{e_2}...), and the system of inequalities

x_e\geq 0,\ e\in E,\quad \sum_{v\in e\in E} x_e=1,\ v\in V,\qquad (*)

Certainly, if x=x_M is the characteristic vector of a perfect matching M of \Gamma, i.e. x is a 0-1 vector with 1s corresponding to the edges of M, it satisfies the system (*) above. Thus maximizing the linear function \sum_{e\in E} w_e x_e on the polytope defined by (*) gives an upper bound on the size of a maximum weight perfect matching in \Gamma w.r.t. the edge weights w_e, e\in E.
But in fact much more holds: namely, this bound is tight, as follows from the following theorem.

For a bipartite graph \Gamma, the vertices of the polytope P defined by (*) have 0-1 coordinates, and are in the one-to-one correspondence with the perfect matchings of \Gamma.

Proof. Let x be a vertex of P, and X be the support of x, i.e. X=\{e\in E\mid x_e> 0\}. Then X does not contain a cycle. Indeed, a cycle in X can be decomposed into the disjoint union of two (not necessarily perfect) matchings, say M and N, as \Gamma is bipartite and so each cycle in \Gamma is even. Observe that \sum_{v\in e\in E} ((x_M)_e-(x_N)_e)=0 for any v\in V.
Thus there exists \epsilon>0 such that x\pm\epsilon(x_M-x_N)\in P, and so 2x=(x+\epsilon(x_M-x_N))+(x-\epsilon(x_M-x_N))), contradicting the assumption that x is a vertex (and so it cannot be a convex combination of two points in P).

Thus X is a forest. Let e\in X be a leaf of a subtree of X. Then (*) implies that x_e=1. Therefore any connected component of X is an edge, and so X is a matching. It is a perfect matching by (*). QED.

By this theorem, the maximum of \sum_{e\in E} w_e x_e on P is reached on a perfect matching x=x_M. Another almost immediate corollary is the following well-known result on doubly stochastic matrices (an n\times n nonnegative real matrix is called doubly stochastic if its row and column sums are equal to 1.)

A doubly stochastic matrix is a convex combination of permutation matrices.

Indeed, n\times n-permutation matrices (the 0-1 doubly stochastic matrices) are in one-to-one correspondence to the perfect matchings of K_{n,n}, (the characteristic vector of such a matching can be viewed as an n\times n matrix, with rows corresponding to one part of the graph, and columns to the other) and so the doubly stochastic matrices are exactly the points of the perfect matching polytope of K_{n,n}, that has, by our theorem, perfect matchings as vertices (and so any point in it is a convex combination of perfect matchings).

Excercise. Formulate an analogy of system (*) for matchings (not necessarily perfect) in bipartite graphs, and prove the corresponding result for vertices of the polytope in question. Using it, formulate the linear programming problem with optimal value being the size of maximum matching.

Excercise. Show that these constructions fail for non-bipartite graphs.

Bipartite matchings and SDRs

14 September, 2009

Matchings in bipartite graphs and systems of distinct representatives (SDRs) of systems of subsets are closely related. More precisely, let \mathcal{A}=\{A_1,...,A_m\}\subseteq 2^X, for X a finite set. We can construct a bipartite graph \Gamma=(\mathcal{A}\cup X,E), where E=\{(A,x)\mid x\in A\in\mathcal{A}\}.

An SDR of \mathcal{A} is Y\subseteq X such that A_i\cap A_j\cap Y=\emptyset for all i\neq j and |A_i\cap Y|=1 for all i. In particular Y contains exactly one element y_A for each A\in\mathcal{A}.
Then \{(A,y_A)\mid A\in\mathcal{A}\} is a matching of \Gamma saturating the part \mathcal{A}. In particular, it is a maximum matching.
Conversely, a matching of \Gamma saturating \mathcal{A} gives rise to an SDR for \mathcal{A}.

An obvious necessary condition for existing of an SDR for \mathcal{A}
is the following Hall’s condition:

| \cup_{A\in\mathcal{B}} A|\geq |\mathcal{B}|,\qquad \forall\ \mathcal{B}\subseteq\mathcal{A}.

In view of this, Hall’s Theorem for matchings is equivalent to the following

An SDR for \mathcal{A} exists iff it satisfies Hall’s condition.

To see that Hall’s condition is sufficient, we proceed by induction on m. For m=1 the claim is obvious. Assume that it is true for all collections of less than m sets. We now establish that it holds for m-set collections, too.

If | \cup_{A\in\mathcal{B}} A|> |\mathcal{B}|,\quad \forall\ \mathcal{B}\subset\mathcal{A}, then we take any A\in \mathcal{A} and set y_A=y for some y\in A. Now by induction there is an SDR Y' for \mathcal{A}\setminus\{A\}. Then \{y_A\}\cup Y' is an SDR for \{B\setminus\{y_A\}\mid B\in\mathcal{A}\}.

In the remaining case there exists k< m such that | \cup_{A\in\mathcal{B}} A|=|\mathcal{B}|=k,\quad  \mathcal{B}\subset\mathcal{A}. By induction, there is an SDR Y' for \mathcal{B}.
Let \mathcal{C}\subseteq \mathcal{A}\setminus\mathcal{B}. Then | \cup_{A\in\mathcal{C}} A\setminus Y'|\geq |\mathcal{C}|=s, for otherwise | \cup_{A\in\mathcal{C}\cup\mathcal{B}} A|< s+k, contradicting Hall’s condition. Now we can take an SDR Y'' for \{A\setminus Y'\mid A\in\mathcal{A}\setminus\mathcal{B}, and observe that Y'\cup Y'' is an SDR for \mathcal{A}.

5-list-colouring of planar graphs

8 September, 2009

A \mathcal{C}-list-colouring of a graph \Gamma=(V,E) with a colour list \mathcal{C}=\{C(v_1),\dots,C(v_n)\}, for V=\{v_1,\dots,v_n\}, is a proper colouring of V by elements of \cup_j C(v_j) so that the adjacent vertices u,v are coloured in different colours and the colour for v\in V is in C(v). In particular, when all the C(v)'s are equal to each other we have a classic graph colouring.

\Gamma is called k-choosable, or k-list-colourable if it is \mathcal{C}-list-colourable for any \mathcal{C} satisfying |C(v)|\geq k for all v\in V. The minimal k for which is \Gamma is k-choosable is called the list chromatic number of \Gamma and denoted by \chi_\ell(\Gamma). Certainly, \chi(\Gamma)\leq \chi_\ell(\Gamma).
It is not hard to construct examples when \chi(\Gamma)< \chi_\ell(\Gamma), e.g. take \Gamma=K_{2,4} and consider \mathcal{C}=\{\{1,2\},\{3,4\},\{1,3\},\{1,4\},\{2,3\},\{2,4\}\}, where vertices v_1,v_2 in the size two part of \Gamma get colour sets C(v_1)=\{1,2\}, C(v_2)=\{3,4\}.

Using the fact that each planar graph has a vertex of degree at most 5, as can be easily established using the Euler formula, one can prove that each planar graph is 6-choosable (employ induction by removing a minimal degree vertex).

It is less easy to show that

any planar graph \Gamma is 5-choosable.

This was established in 1994 by Thomassen.
In fact \chi_\ell(\Gamma)=5 cannot be improved — there are examples of planar \Gamma for which \chi_\ell(\Gamma)=5. The smallest known (in 2003) example has 63 vertices.

The classical analogy of this, the Heawood theorem that says that each planar graph is 5-colourable, is known since 1890, and the 4-colourability is a recent and quite difficult result by Appel and Haken.

To show the 5-choosability, one first observes that it suffices to prove it for the planar graphs for which every face, except possibly the exterior face of the plane embedding, is a triangle. We call such graphs almost triangulated. Then, one proceeds by induction on |V|. Assume that we know that for any almost triangulated planar \Gamma with |V\Gamma|\leq n, exterior face B, and \mathcal{C} such that |C(v)|\geq 3 for all v \in B, resp. |C(v)|\geq 5 for all v\in V\setminus B, we can extend a proper \mathcal{C}-list-colouring of an edge on B to a full proper \mathcal{C}-list-colouring (as is obviously true provided |V|\leq 3, giving us a basis of induction).

Let us now show this for \Gamma with |V\Gamma|=n+1. Let (x,y) be an edge of B that we colour using \alpha\in C(x) and \beta\in C(y)\setminus\{\alpha\}.
If B has a chord, i.e. there is an edge (u,v) that joins two non-adjacent vertices of the cycle induced on B (and so (u,v) is not cutting through the fact bounded by the cycle on B), we spilt \Gamma into two planar parts \Gamma_1 and \Gamma_2, so that \Gamma_1 and \Gamma_2 have (u,v) in common. W.l.o.g. (x,y)\in E\Gamma_1; by induction, we can extend this colouring to a \mathcal{C}-list-colouring \mathcal{A}_1 of \Gamma_1. This colouring will fix a proper \mathcal{C}-list-colouring of the edge (u,v), that is on the exterior face of \Gamma_2. Again, by induction, we can extend this colouring of (u,v) to a \mathcal{C}-list-colouring \mathcal{A}_2 of \Gamma_2. Combining \mathcal{A}_1 and \mathcal{A}_2, we obtain a \mathcal{C}-list-colouring of \Gamma, as required.

It remains to consider the case when B does not have a chord.
Then let z\in B\setminus\{x,y\} be the vertex adjacent to x. Take any two colours \delta,\mu in C(z)\setminus\{\alpha\} (this is possible as |C(z)|\geq 3) and remove \delta,\mu from C(t) for all t\in\Gamma(z)\setminus B. Then remove z and all the edges on it from \Gamma. We obtain a planar graph \Gamma' with one vertex less, and with the valid exterior face conditions. By induction, we can extend the colouring of (x,y) to a \mathcal{C}-list-colouring of \Gamma'. It remains to see that z can be properly coloured, too. Indeed, we can colour it with either \delta or \mu, depending on the colour of the neighbour of z on B distinct from x. Q.E.D.

we had a midterm last week…

10 March, 2009

funny pictures of cats with captions
more animals