# Numerical Solutions to the Variational Problems by [PERSON]'s Path-Finding Algorithm
## 6 Brachistochrone Problem  
Consider a particle is constrained to move from rest along a path on the xy-plane between two fixed endpoints in a uniform gravitational field near the Earth's surface. The brachistochrone problem is finding the path where the particle will take the minimal ToF. This problem was first solved by [PERSON] in 1696 and is the milestone in the invention of the calculus of variations [29]. Engineers and designers of roller coasters use the path to accelerate the car to the highest speed possible in the shortest possible vertical drop. The skier and cyclist follow the path, which results in a minimal lap time [30]. Assuming no air resistance and friction, the speed of the particle at the vertical distance y can be obtained from the principle of energy conservation,  
\[\mathrm{v}(\mathrm{y})=\sqrt{2\mathrm{gy}}, \tag{23}\]  
where g is the gravitational acceleration near the Earth's surface. Note that the initial position of the particle is at the origin of the coordinate system, and the positive direction of the y-axis points downward. If the particle path is described by the functions y(x), the ToF of the particle can be calculated from the integral:  
\[\mathrm{t}_{\mathrm{f}}=\int_{\mathrm{a}}^{\mathrm{b}}\frac{\mathrm{ds}}{ \mathrm{v}}=\int_{\mathrm{x_{i}}}^{\mathrm{x_{f}}}\frac{\sqrt{1+y^{\prime 2}} \mathrm{dx}}{\sqrt{2\mathrm{gy}(\mathrm{x})}}. \tag{24}\]  
The optimum path can be obtained by minimizing this integral. Now, we have the functional F = \(\sqrt{\left[1+y^{\prime 2}\right]/2\mathrm{gy}(\mathrm{x})}\). Since F does not explicitly depend on x, we can use the Beltrami identity [31] to rewrite the Euler-Lagrange equation as  
\[\mathrm{F}-y^{\prime}\bigg{(}\frac{\partial\mathrm{F}}{\partial y^{\prime}} \bigg{)}=\mathrm{C}, \tag{25}\]  
Figure 7: Comparison of the ray tracing in the axial index of refraction profile. Solid lines are the exact solutions, and the dashed lines are the simulation results from [PERSON]’s algorithm. where C is a constant. Substituting for F, we can express the Euler-Lagrange differential equation as  
\[\mathrm{y}\left(1+\mathrm{y^{\prime}}^{2}\right)=1/\mathrm{C^{\prime}}^{2}, \tag{26}\]  
where \(\mathrm{C^{\prime}}=\sqrt{2\mathrm{g}}\mathrm{C}\). The solution of this equation has the shape of a cycloid [32], which can be represented in a parametric form as  
\[\mathrm{x}=\mathrm{c^{\prime}}\left(\Theta-\sin\,\Theta\right),\mathrm{y}= \mathrm{c^{\prime}}\left(1-\cos\Theta\right). \tag{27}\]  
The constant \(\mathrm{c^{\prime}}=1/2\mathrm{C^{\prime}}^{2}\) needs to be evaluated numerically from the endpoint position. The minimum ToF can be determined analytically as  
\[\mathrm{t_{f}}=\Theta_{\mathrm{end}}\sqrt{\mathrm{c^{\prime}}/\mathrm{g}}, \tag{28}\]  
where \(\Theta_{\mathrm{end}}\) is the value of \(\Theta\) at the endpoint. To simulate the ray path using [PERSON]'s algorithm, we can simply use the method described in Section 3. The change is only on the definition of the particle speed. We can define the particle speed at each vertex as  
\[\mathrm{v_{i}}=\sqrt{2\mathrm{gy_{i}}}, \tag{29}\]  
where \(\mathrm{y_{i}}\) is the y-coordinate of the vertex i. The weight of each edge can then be defined as in Equation (12). The actual path can be approximated as the one that minimizes the ToF in Equation (13). A preliminary study of this simulation can be found in [5]. However, the numerical results in this work are quite poor. The square network with next-nearest neighbor connections is used in this work, which introduces large numerical errors into the calculation. We improve the accuracy of the calculations by using the two-dimensional Moser lattice in our simulation. Figure 8 shows the resulting brachistochrone curves with various endpoints. The dashed lines are the paths obtained from [PERSON]'s algorithm, while the solid lines are the exact solutions from Equation (27). In all simulations, we use the 40\(\times\)30-unit square lattice (\(\Delta\mathrm{x}=\Delta\mathrm{y}=1\)) with 15 sub-lattices on each plaquette side.