Rumors of theorems about reflections in closed curves or polygons were that they were almost always ergodic. The ‘almost always’ leaves ample room for exceptions and the ellipse reflections are never ergodic. Reflections are ergodic if they pierce a short line segment with a frequency independent of the location or orientation of the segment within the enclosure. A ray in an ellipse either:
• intersect the line segment between the foci in which case the reflections define an envelope which is a confocal hyperbola,
• or it goes outside the foci in which case the reflections define an envelope which is a confocal ellipse,
• or it goes thru a focus and all the subsequent reflections go thru alternate foci and converge on the major ellipse axis.
None of these are Ergodic. This image from this program suggests that Descartes’ cubic folium behaves like an ellipse.

### Program Logic

Descartes’ folium is x3 + y3 = 3axy. We add a constant to study a variant and use p(x, y) = x3 + y3 − exy = c for constants e and c. See function p. We choose a point (x, y) in the square [0, 1]2 and then pick c as p(x, y). This starts out on the chosen curve—actually chooses the curve to go thru the chosen point. (xd, yd) are the direction of the ray from (x, y). To find the next point of reflection we exploit the fact that we start from a point on the curve and this avoids solving a cubic equation. We write the points on the ray parametrically using z as a linear parameter. f(z) is then a 3rd degree polynomial in z, but f(0)=0. We extract the coefficients of the polynomial f knowing that the constant term is 0 and are left with solving a quadratic which we do by high school methods. The comments at the very end of the file are elementary and error prone derivation of the solution. Here are two variant cubics on the folium that do not include the origin.

We need a tangent or normal to do the reflection and the gradient of p is just the normal vector (px, py).

Constants in the program to treat as parameters are:

• x, y: in effect choosing a new c.
• xd, yd: to choose initial ray, only ratio is significant,
• e: to scale the curve linearly,
• X, Y: if you have a different display size,
• 300 in q<300 for how many reflections.
I compile with:
```javac Ergodic.java
java Main pix.png```
I must usually adjust the size of the window to see the effects of the calculation on the screen. A java.awt guru could probably fix the bug. This is the .png image that results. Here we begin at x=0.05, y=0.05, xd=1, yd=1.1. There appears to be an avoidance of the middle. From the latter image it is clear that the angle of reflection is not merely a function of position along the curve. Such a relation might be guessed from the first image.

This OCaml program with about the same logic makes this image. See this to run on a Mac. This version is interactive. If you click on a point in the square display each of the two coordinates is mapped to a point on the curve in the first quadrant and the chord between them is the initial ray. As each chord determines the nest via reflection, we have a bijection of the square to itself. The ergodic question is thus about orbits on the square. If we declare that each point on the diagonal maps to itself, then we have continuity.