# Can we always find such a function?

suppose there is any arbitrary function of variables q, q' and t,

$L = L(q, q', t)$ where $q' = \frac{dq}{dt}$

can we always find a function $Z(q, t)$, such that,

$L = \frac{dZ}{dt}$

note:

$L, q, t \in$ {$C^{\infty}$}

-

I assume you mean the total differential, and you want a $Z$ that depends on the form of $L$ but not the form of $q$ (i.e. $q$ is merely treated as an argument). In which case the chain rule gives $$L=\frac{dZ}{dt}=\frac{\partial Z}{\partial q}q'+\frac{\partial Z}{\partial t}.$$ So a necessary condition is that $L$ is linear in $q'$ (formally). Furthermore, if we write $L=uq'+v$, it is necessary that $(u,v)$ have a potential function (namely $Z$), so (and this is locally sufficient), $$\frac{\partial u}{\partial t}=\frac{\partial v}{\partial q}.$$