Is it possible to formulate the following optimization problem using a Lagrangian framework? Consider the following dynamical system describing the trajectory of an object moving in the $(xz)$ plane from $(0,1)$ to $(1,1)$,
    \begin{align}
  \frac{\mathrm{d} x}{\mathrm{d} t} &= \cos\psi + \frac{3\alpha}{8z^2} \, \sin(2\psi) \, , \\
  \frac{\mathrm{d} z}{\mathrm{d} t} &= \sin\psi + \frac{3\alpha}{16z^2} \left( 1-3\cos(2\psi) \right) \, ,
 \end{align}
where $\psi$ is a real number (possibly varying in time/space) and $\alpha \in [-10,10]$.
As mentioned above, the boundary conditions are $z(x=0)=1$ and $z(x=1)=1$.
We now set $z^\prime := \mathrm{d}z/\mathrm{d}x$ and define the system Lagrangian as
\begin{equation}
 \mathcal{L}_\pm := \frac{1}{\left|\cfrac{\mathrm{d} x}{\mathrm{d} t} \right|} \, ,
\end{equation} 
that minimizes the travel time 
$$
\tau = \int_{0}^{1} \mathcal{L} \, \mathrm{d} x \, .
$$
The trajectory of the object can then be obtained by solving the classical Euler-Lagrange equation
\begin{equation}
 \frac{\mathrm{d}}{\mathrm{d} x} \frac{\partial \mathcal{L}}{ \partial z^\prime} - \frac{\partial \mathcal{L}}{\partial z} = 0 \, .
\end{equation}
However, since the original equations involve an additional parameter $\psi$, it becomes hard to formulate the problem using a Lagrangian framework.
i was wondering whether there exists a method that could help dealing with such optimization problems.
Any help or hint is highly appreciated.
Thank you!
 A: The answer is simply no. There is no way to formulate this optimization problem into a Lagrangian framework. The reason is that the variable $\psi$ cannot be eliminated so as to obtain a single equation involving only $z$ and $z^\prime$. More generally, the Lagrangian can also be a function of $x$. 
The possible way to approach this problem is either to specify the law of $\psi$, i.e. prescribe the orientation of the object as an input before calculating the Lagrangian, or alternatively impose a condition on $\psi$ that renders its elimination possible. In the latter case, assuming the small angle approximation, $\psi \ll 1$ allows taking $\sin(\psi) \sim \psi$ and $\cos(\psi) \sim 1$. Accordingly, the Lagrangian can easily be calculated. However, this assumption implies that the Euler-Lagrange equation does not yield a second order differential equation in $x$ (can readily be checked). Thus taking higher-order terms in the expansions of the sine and cosine functions becomes necessary. Restricting these up to second order in $\psi$ and solving for the system Lagrangian yields two possible values as indicated in the related post by OP.
Then, the Lagrangian that should be considered is the one leading to the shortest travel time from $(0,1)$ to $(1,1)$. However, it can be checked that the small angle approximation can sometimes be violated thus making the expansion not an appropriate way to handle this problem anymore. 
Consequently, I highly recommend that you try an alternative approach basing on e.g. optimal control  theory to solve this problem since looking for a Lagrangian description is far from being trivial. 
