New challenges

Life has been pretty busy recently. I worked on my Google Summer of Code project implementing lattices in Sage; I continued working on several optimization projects, mostly dealing with the charging of multiple electric vehicles (in cooperation with FH Joanneum Kapfenberg and other companies); I took my last exams and finished my master’s thesis (“Optimization of a Purlin Punching Process”). I’m glad (and a little proud) that all of this worked out so well.

Adding to that, I organized my move to the U.S., where I finally landed and already began working for Wolfram Research. I am working as a Kernel Developer on Mathematica Online (or whatever it will be called once it gets released to the public). This is quite related to my previous work on Mathics.

Now, the sad news is that I have to stop actively coding on Mathics as a consequence. However, I see it in really good hands with Angus having already taken the lead recently, and he will certainly continue to keep Mathics flourish. Others are jumping in as well, so Mathics will not disappear, but grow further. Of course, I will still be there when assistance is needed, to merge in pull requests, and to keep the server running.

I’m really excited about the new challenges. I’ll share some of my experience on a special (rather personal) blog Go West, Young Jan. It’s in German so I don’t forget my mother’s tongue completely.

Let the adventure begin.

Extreme Geeky Tidying Up: Sorting image colors with Python and Hilbert curves

There are levels of tidiness.

Tidy.
Very Tidy.
Totally Deranged Tidy.

Geeky Tidy.

After sharing these awesome pictures by the Swiss “artist” Ursus Wehrli with the world, Martin N. pointed out that there is still a severe issue with the Badewiese: People are not even sorted by the colors of their swimsuits! Adding to that, trees are placed in total chaos, not to speak of their leaves; clearly, there are tiny waves on the water; and one can almost see blades of grass not being sorted by size. Obviously, this picture needed further tidying up.


© Ursus Wehrli

Python to the rescue! 5 minutes, 10 lines, and half a beer later I had a program that would load the image, re-arrange its pixels, and save it again:

from PIL import Image

old = Image.open("tidy.jpg")
colors = old.getcolors(old.size[0] * old.size[1])
data = []
for count, color in colors:
    data.extend(count * [color])
data.sort()
new = Image.new('RGB', old.size)
new.putdata(data)
new.save("naive_tidy.png")

This yields the following picture:

So how was this “re-arrangement” performed? In a naïve approach, I just sorted the RGB values of the pixels, which is why there are many consecutive lines (of equal reds) with abrupt changes. Ordered, but far from being tidy.

Let’s try another color space and sort by HSV values—a smooth hue should look better, after all. So by adding

import colorsys

and changing one line to

data.sort(key=lambda rgb: colorsys.rgb_to_hsv(*rgb))

we get the following image:

More beautiful, but the red and white noise in the end doesn’t look tidy at all. We want a smooth transition through all given colors. Hilbert curves to the rescue! Found a ready-to-be-used Hilbert walk implementation, added

import hilbert

and changed the sorting once again to

data.sort(key=hilbert.Hilbert_to_int)

to get this image:

Mathematical computer science just made the world a little tidier.

ECCO XXIV in Amsterdam

Attended the 24th conference of the European Chapter on Combinatorial Optimization (ECCO XXIV) in Amsterdam from May 30 to June 1. I gave a presentation about our current work on punching process optimization. You can download the slides if you want (though they’re much cooler with me talking to them, of course ;) ). Heard an amazing talk by plenary speaker Gerhard Woeginger on “transportation under nasty side constraints.” Even (or especially) in our digital world, overhead transparencies can be just awesome!

After the official part of the conference, I stayed the rest of the week and further explored Amsterdam. Went to the zoo with Daniel Krenn, who happened to be in Amsterdam over the long weekend as well, and visited the Van Gogh Museum. Met my Dutch Erasmus buddies Lyor and Joost on Saturday. See some pictures below.

Mathics goes open source

I’ve been working a lot on Mathics again during the last weeks. All towards the goal that I’ve had in mind for a long time: to release it as open source. After all, that’s the only thing that could set Mathics apart from Mathematica—the only thing that’s not so good about Mathematica is that it’s not free, neither as in freedom nor as in free beer.

If you wonder what Mathics is: it’s a general-purpose computer algebra system implementing the awesome Mathematica mathematics/programming language. Some of its most important features are

  • a powerful functional programming language,
  • a system driven by pattern matching and rules application,
  • rationals, complex numbers, and arbitrary-precision arithmetic,
  • lots of list and structure manipulation routines,
  • an interactive graphical user interface right in the Web browser using MathML (apart from a command line interface),
  • creation of graphics (e.g. plots) and display in the browser using SVG,
  • an online version at www.mathics.net for instant access,
  • export of results to LaTeX (using Asymptote for graphics),
  • a very easy way of defining new functions in Python,
  • an integrated documentation and testing system.

Read the manual to learn more about the over 350 built-in functions and symbols in Mathics.

The actual heavy math stuff (like integration) is mostly done by the Python package SymPy. There is optional support for functions depending on Sage as well. Despite “out-sourcing” most mathematical functions, Mathics has more than 20,000 lines of Python code already, dealing with much non-trivial stuff such as parsing Mathematica input, pattern matching, graphics generation, etc.

Unfortunately, Firefox is the only browser supported so far, because no other browser supports MathML yet. However, this is expected to change pretty soon when Webkit (used by Safari and Chrome) adds MathML support. I wonder whether Internet Explorer will ever get that far.

I set up a project homepage at www.mathics.org for organizational stuff, while www.mathics.net is still the place for the online interface of Mathics. The source code is hosted at github.

I hope that one day there will be developers joining me. Contact me if you want to get involved!


Formeln und Sätze updated

Gunnar Krug found a trivial error in my collection of theorems and formulas for the mathematical olympiad (see math documents). Updated the document, also improving the overall appearance a little bit. However, there’s still so many things I would do different if I wrote the document now (it’s been way back in 2004 or so). But sorry, haven’t got enough time to fix these things right now!

Stanzoptimierung

Finished the optimization project I’ve worked on the last few weeks: Together with Eranda Dragoti-Cela, Elisabeth Gassner, Johannes Hatzl and Bettina Klinz I created a C++ program that optimizes the configuration and punching plan of a punching machine. The machine will start to operate in a Polish factory this summer. Below are some pictures of it.

Punching machine 1

Punching machine 2

Punching machine 3

Mathematik C für Elektrotechniker

Published the script I wrote for third semester mathematics for electrical engineers. This is a joint 2007/08 work with Florian Lehner, based on work by Christian Meisl dating back to 1995. It’s still full of errors and typos, so please contact me if you find any! See the math documents page for the download link.