I am trying to solve an inverse problem based on variational principle.

I will first present a forward problem that is already solved, and then present the inverse problem that I am trying currently to solve.

**The forward formulation of the problem is the following:**

Given a known function $f(x)$, an unknown optimal deterministic trajectory $z_m(t)$ is defined by a variational principle
$$
\delta \int\limits_a^b L(\dot{z},z) dt = 0
$$
with $z_m(a) = x_0$ and $z_m(b) = x_f$.

So $z_m$ is the minimiser of the Lagrangian $L$ that involves the function $f(x)$, and we can formulate Euler-Lagrange equations
$$\DeclareMathOperator{\D}{\operatorname{d{\!}}}
\frac{\D}{\D t} \frac{\partial L(\dot{z},z)}{\partial \dot{z}} = \frac{\partial L(\dot{z},z)}{\partial z}
$$
to identify $z_m(t)$ for $t \in [a,b]$.

**The inverse problem I am trying to solve:**

If the function $f(x)$ is unknown but optimal deterministic trajectory $z_m(t)$ that is the minimiser of the Lagrangian $L$, is known, I want to find a way to identify $f(x)$ in a functional form.

The Lagrangian (whose $z_m$ is a minimiser) is of the form $$ L(\dot{z},z) = \frac{1}{\sigma^2} \big( f(z) - \dot{z} \big)^2 -\frac{\partial f(z)}{\partial z}, $$ so it involves both the function $f$ and it's 1st derivative ($\sigma$ here is some constant).

From the Euler-Lagrange equations I can obtain an equation that involves $f$ and its derivatives evaluated at the known optimal trajectory $z_m(t)$.

So in essence I have an equation of the form $$ \ddot{z}_m(t) = \frac{\sigma^2}{2} \frac{\partial^2 f(z_m(t))}{\partial z^2} + \frac{\partial f(z_m(t))}{\partial z} f(z_m(t)). $$ Since I know $z_m$ in a functional form, I could evaluate $z_m$ and its derivatives within the interval. However, since the equation that I obtain for $f(x)$ contains both $f$ and its derivatives I do not know how to proceed, or whether this problem is solvable at all.