A stable position can obviously be found for a three-legged table on an uneven surface. It is also true that a stable position can also be found for a rectangular four-legged table on a smoothly uneven surface. Rotate the table, keeping the same three legs on the surface, and a stable position must be found before the table reaches a position similar to the starting position.

As an exercise, a Python script was written to simulate this method of stabilising a wobbly table. For the height of the surface, a 5 × 5 grid of random integers in the range 0 - 49 was resized to 1000 × 1000 by bicubic interpolation. This surface is mapped in the diagram below by colouring grid points with odd values white and grid points with even values grey.

A 200 × 200 table is placed with its centre at a given position. Placing three legs of a table on a continuous surface requires finding vertices on the surface which form a triangle with sides of the correct length. In the simulation, the vertices are constrained to fall on grid points, so the lengths of the sides are usually not exactly right. The vertices are jiggled to get the best match to the side lengths, while keeping the centre of the diagonal (and of the table) constant in the *x*-*y* plane. The fourth leg of the table is positioned to make opposite edges of the table parallel in 3D space.

To rotate the table, the vertices of the diagonal of the surface triangle are jiggled by -1, 0, +1 in the *x* and *y* directions in such a way that they rotate clockwise about the centre of the diagonal. The other vertex is jiggled by -1, 0, +1 in all directions. The position is chosen which minimises the side length errors. The table is stable when the z coordinate of the fourth leg is on the surface at its grid point:. Each rotational step must change the *x* - *y* coordinates of at least two of the vertices, so the height of the fourth leg can change by two or more units. This could result in the stable position being missed.

The distance of the fourth leg from the surface can be plotted as the table rotates through 180º.

For a rectangular table, especially a long one, where the ends can be in well-separated regions of the surface, the behaviour is more complicated (as is the proof Mathematical table turning revisited that there is a stable position, which is clearly explained by Burkard Polster):-

This diagram shows the rotation to stability of the table as it is moved around on the surface. It would of course have been less jerky without the discrete approximations of this simulation.

The procedure works just as well for a rectangular table, although it may be necessary to rotate it by more than 90º to achieve stability:-

Here is a table which increases then decreases in length:-

Finally, an improved simulation was devised in which real instead of integer values were used for the positions of the table legs and the height of the surface. The table was rotated by 0º to 180º about a vertical axis through its centre, and a method was found to settle it on the surface while preserving the direction one of its diagonals as seen from above. This gives a smoother plot of the distance of the fourth leg from the surface:-

If a stable table keeps moving perpendicular to one of its sides to an adjacent stable position it traces out a path as shown below. It changes direction by 90º when it gets to close to the edges of the surface.

It sometimes returns close to its starting position. The path is shown below.

By calculating the degrees of rotation to achieve stability at each of the 1000 × 1000 grid points on the surface, a contour map of the rotations can be produced. Here, the above path is superimposed on this contour map.

Christopher B. Jones 2023-04-07