## Thursday, February 28, 2008

### Zeit Sudoku Bookmarklet

As you know, I am a Sudoku addict. For a nice ten minute break I often download the daily sudoku from Die Zeit. Until recently, from this bookmarked page, I had to change the level from "leicht" to "schwer" and then press the button for the PDF version to print out.

But now, they introduced even another page before that (where you have to choose between the Flash version and the puzzle from the printed (only weekly) newspaper or the oldstyle version that allows the download. You could no longer bookmark the next page as there the URL already contained some sort of session ID.

Of course, they want me to go through all these pages to make sure I do not miss any of the ads they want to present me. But I think that this new version requires a few mouse clicks too much and so I decided to have a look at the page's source code.

It turns out that the URL for the PDF no longer contains a session ID but instead contains today's date, slightly more than you can do with a static bookmark. But that got me thinking that one might be able to solve this problem with a bookmarklet, a bookmark that makes use of the fact you can have JavaScript in a URL and in a bookmark.

Last time I looked into JavaScript was roughly ten years ago and at that time it seemed like a very stupid idea to have some crippled language where you have to transmit all of the source code to the browser which then slowly interprets it if you can do much much more powerful things on the server side with CGI scripts.

Since then, a lot of time has passed and I have heard many interesting things (let me mention only AJAX) suggesting I should maybe reconsider my old dismissal of JavaScript. I had a look though a number of reference sheets and here it is: My first own JavaScript sniplet: A sudoku download bookmarklet. Clicking on this link (or bookmarking it and retrieving the bookmark) brings you directly to the PDF version on the latest "schweres" sudoku! Here is the source:

javascript:var d=new Date();  var m=d.getMonth()+1;  if(m<10){m="0"+m};  var t=d.getDate();  if(t<10){t="0"+t}; open('http://sudoku.zeit.de/sudoku/kunden/die_zeit/pdf/sudoku_' +        d.getFullYear()+'-'+m+'-'+t+'_schwer.pdf')

## Thursday, February 07, 2008

### Geometric Hamilton Jacobi

Today, over lunch, togther with Christian Römmelsberger, we tried to understand Hamilton-Jacobi theory from a more geometric point of view.

The way this is usually presented (in the very end of a course on classical mechanics) is in terms of generating functions for canonical transformations such that in the new coordinates the Hamiltonian vanishes. Here I will rewrite this in the laguage of symplectic geometry.

As always, let us start with a 2N dimensional symplectic space M with symplectic form . In addition, pick N functions such that the submanifolds are Lagrangian, that is is a Lagrangian subspace of (meaning that the symplectic form of any two tangent vectors of vanishes). If this holds, the can be regarded as position coordinates.

Starting from these Lagrangian submanifolds, we can locally find a family of 1-forms in the normal bundle such that . You should think that for appropriate momentum coordinates on the Lagrangian leaves of constant . But here, these are just coefficient funtions to make a potential for .

Now we repeat this for another set of position coordinates which we assume to be "sufficiently independent" of the meaning that . This implies that locally are coordinates on M. With the comes another 1-form and since are locally related by a "gauge transformation". We have for a function F.

Let's look at a little bit closer. A general normal 1-form would look like . But since we started from Lagrangian leaves, there is no in and thus . But expressing this in coordinates yields

Comparing coefficients we find and . You will recognize the expressions for momenta in terms of a "generating function".

What we have done was to take two Lagrangian foliations given in terms of and and compute a function from them. The trick is now to turn this procedure around: Given only the and a function of these and some N other variables , one can compute the as functions on M: Take a point and define by inverting . For this remember that was defined implicitly above: It is the coefficient of in .

Up to here, we have only played symplectic games independent of any dynamics. Now specify this in addition in terms of a Hamilton function h. Then the Hamilton-Jacobi equations are nothing but the requirement to find a generating function such that the are constants of motion.

Even better, by making everything (that is h and Q and F) explicitly time dependent, by the requirement that the action 1-form is invariant: giving we get a transforming Hamilonian and we can require this to vanish:

If we think of the Hamiltonian h given in terms of the coordinates this is now a PDE for F which has to hold for all . That is, writing F as a function of and it has to hold for all (fixed) as a PDE in the and t.