One of Euclid’s axioms states that lines can be extended indefinitely. If we have to be content with a finite canvas, like the rectangle below, we have to resort to a trick to keep lines going when they hit the boundary of the canvas. One such trick is to allow the line to re-enter the canvas at the corresponding position on the opposite side of the canvas. Those of us who have been exposed to asteroids in their dark past are familiar with this. Lines with rational slope will thus look like this:

If the slope is irrational, they will become dense, i.e. come arbitrarily close to any given point on the canvas. In either case, all segments of a given line are parallel. This changes when we switch to hyperbolic geometry, represented by the upper half plane, where lines (now called geodesics) are half circles perpendicular to the boundary, or vertical lines.

Above you see three such geodesics, forming the boundary of the shaded region, which will be our canvas. This canvas is the classical fundamental domain of the modular group. If we want to follow hyperbolic geodesics in this canvas, we have to explain what to do when a geodesics hits one of the sides of this infinite triangle. This is easy for the left and right vertical edges: If the green geodesics exits at the right hand side and becomes purple (due to lack of oxygen), it is translated back to the left. This translation by -1 is in fact not only a Euclidean congruence, but also a hyperbolic one.
When a geodesic tries to exit at the circular bottom, it is rotated back, using a hyperbolic rotation by 180º about the point √-1, which is in complex numbers given by z↦-1/z. That’s a bit harder to visualize for our Euclidean eyes. One way to think about it is to find the point where the green geodesic becomes purple, take the corresponding point on the other side of the black dot on the bottom red half circle, and continue with a purple geodesic up into the shaded region by making the same angle as the one you made when exiting.

This allows to draw hyperbolic geodesics just like we did in the rectangle with Euclidean lines. Below is a more complete picture that shows how much more complicated or chaotic this is becoming when we keep extending the geodesic. The numbers help to identify end points of segments. How complicated can this get?

The two operations that allow us to continue a geodesic, namely z ↦z±1 and z↦-1/z are exactly the operations that we used last week to find the continued fraction expansion of a real number. This seemingly far fetched connection points to a deep link between number theory and geometry: Take a geodesic in the upper half plane, and look at its left and right end points a<b on the real axis. We will limit our attention to the case that -1<a<0 and 1<b. Write both -a and b as continued fractions, this gives two sequences of positive integers a₁, a₂,… and b₀, b₁, b₂. We combine these into a single bi-infinite sequence …b₋₂,b₋₁,b₀,a₁, a₂,… which we denote by cᵢ.
Now it turns out that continuing the geodesic across the edges changes the sequence cᵢ either into c₋ᵢ₋₁ or into cᵢ₊₂. Either operation represents a mere shift or flip of this sequence. This leads to a remarkable theorem of Emil Artin from 1929: There is a hyperbolic geodesic on this canvas that comes any given hyperbolic segment on the canvas arbitrarily close. So this geodesic is not only dense, but dense in all directions simultaneously.
To see this (a little bit), it suffices to find a suitable bi-infinite sequence cᵢ of integers encoding that geodesic. Take as cᵢ a sequence that contains every finite positive sequence of positive integers as a subsequence. Then, for a given geodesic segment, find its bi-infinite sequence, and truncate it at both ends to get a finite sequence. By truncating further out, we obtain better and ebtter approximations of the given geodesic. As every finite sequence of positive integers is contained in our sequence cᵢ, we will (by continuation) eventually find a segment of the encoded geodesic that is as close to the given segment as we desire.
This theorem of Artin is at the beginning of the study of both geometrical dynamical systems (the geodesic flow) and symbolic ones that are related to number theory and exhibit a chaotic behavior that is not apparent in Euclidean geometry.