# Finding the geodesic on a cylinder

This video was produced by The Kaizen Effect$$^{[1]}$$.

We’ll start off with a very basic problem; the goal of this problem is just to get a feel for how minimization problems are solved using the Euler-Lagrange equation. As we go through multiple problems, hopefully we’ll start to notice patterns and general procedures which were taken in each problem to get the result. The problem we’re going to look at here can be stated as follows: for any two coordinate points $$(x_1,y_1)$$ and $$(x_2,y_2)$$ on the surface of a cylinder, we need to find the curve on the cylinder connecting those two points which has the smallest possible arc length $$S$$. The shortest path between any two points on a curved surface is called a geodesic, to clarify the title of this article and the video above. You could imagine expressing the generalized coordinates $$q_j$$ in Cartesian coordinates as $$(x,y,z)$$ which will represent any curve on the cylinder between the coordinate points $$(x_1,y_1,z_1)$$ and $$(x_2,y_2,z_1)$$. The arc length $$S$$ can be expressed as a functional of these coordinates as

$$S=\int_{P_1}^{P_2}\sqrt{1+\biggl(\frac{dy}{dx}\biggl)^2}$$

where

$$L=\sqrt{1+\biggl(\frac{dy}{dx}\biggl)^2}.$$

(As a side not, $$P_1$$ and $$P_2$$ refer to the starting and ending point of the curve as shown in the video above.) In order to solve the Euler-Lagrange equation for the coordinates $$(x,y,z)$$ which minimize the functional $$S$$, we need to solve them—and to do that, we must take derivatives of $$L$$ with respect to our choice of generalized coordinates. The general character of many problems is to choose generalized coordinates which make evaluating these derivatives the easiest. For this reason, we’ll choose our generalized coordinates to be polar coordinates. The algebraic and trigonometric manipulations used to express our Cartesian coordinates and arc length in terms of polar coordinates are shown in the video and, for convenience, I’ll also list them below$$^1$$:

$$x=Rcosθ ⇒ dx=-Rsinθdθ$$

$$y=Rsinθ ⇒ dy=-Rcosθdθ$$

$$z=z ⇒ dz=dz$$

$$dS=\sqrt{dx^2+dy^2+dz^2}=\sqrt{R^2cos^2θ^2+R^2sin^2θdθ^2+dz^2}=\sqrt{(Rdθ)^2+dz^2}=\sqrt{dθ^2[R^2+(\frac{dz}{dθ})^2]}$$

$$S=\int_{θ_1}^{θ_2}\sqrt{R^2+(\frac{dz}{dθ})^2}dθ$$

The whole point of all that was just to express $$S$$ as functional of the form $$S(z(\theta), z’(\theta), \theta)$$ in terms of polar coordinates because, according to our derivation, only then can we solve for the curve $$z(\theta)$$ (using the Euler-Lagrange equation) which minimizes $$S$$. (It is very important to always know what we’re actually trying to do in these kinds of problems; it is all too easy to get lost in the math and lose track of what we’re actually trying to accomplish.) To actually solve the Euler-Lagrange equation to find the curve $$z(\theta)$$ whose arc length is minimized, we’ll need to solve that differential equation. To do this, we’ll evaluate each of the derivatives as shown in the video and below:

$$\frac{∂L}{∂z}=0$$

$$\frac{∂L}{∂z’}=\frac{1}{2}\biggl(R^2+(\frac{dz}{dθ})^2\biggl)^{-\frac{1}{2}}(2z’)=\frac{z’}{R^2+(\frac{dz}{dθ})^2}$$

$$\frac{d}{dθ}\biggl(\frac{z’}{R^2+(\frac{dz}{dθ})^2}\biggl)=0$$

Something very nice happened to the equation on the bottom which, in general, does not happen; we see that the derivative $$(\frac{z’}{R^2+(\frac{dz}{dθ})^2})$$ is equal to zero; if the rate-of-change of that single variable function is zero, then it must be a constant:

$$\frac{z’}{\sqrt{R^2+(\frac{dz}{dθ})^2}}=C.$$

($$C$$ represents any arbitrary constant.) To make sure we’re not getting lost in the math, I’ll repeat and continue to repeat, our goal is to find $$q_j(\theta)=(z(\theta),R(\theta)=constant)$$ which is the curve that minimizes $$S$$. So what we’re going to do is some algebraic manipulations on the equation above to try to isolate $$z(\theta)$$. The first thing that immediately comes to my mind is to integrate both sides to get rid of that derivative on the left-hand side of the equation above. You might try integrating both sides of the equation as it currently is, but let’s do some algebra first (written below) to simplify the thing that we’re taking a derivative of:

$$\frac{z’}{\sqrt{R^2+(\frac{dz}{dθ})^2}}=C.$$
$$\frac{z’^2}{R^2+z’^2}=C^2=A$$
$$z’^2=A(R^2+z’^2)$$
$$z’^2(1-A)=AR^2$$
$$z’^2=\frac{AR^2}{1-A}$$
$$z’=\sqrt{\frac{AR^2}{1-A}}$$

Notice that the expression on the right-hand side of the bottom equation is a constant. Let’s represent the right-hand side by $$m$$ as in the video. Since $$m$$ is just a constant when we integrate both sides with respect to the independent variable $$θ$$, we get:

$$z(θ)=mθ+b.$$

This equation gives us the shortest path between two points $$P_1$$ and $$P_2$$ if we unraveled the cylinder and flattened it out into a flat plane. If you imagine rolling this plane back up again, the shape that $$z(θ)$$ will trace out along the surface of the cylinder will be a helix. The Euler-Lagrange equation can be used to find the geodesic on any curved surface. A similar procedure to what we did in this section involving finding the geodesic of a cylinder can be generalized to find the geodesic along any surface.