# A stationary action principle for an oscillator with position-dependent damping

I wonder if the equation of motion of an oscillator with (position-dependent) damping $$\begin{equation*} \ddot{x}+\gamma(x)\dot{x}+\omega_{0}^{2}x=0 \tag{1} \end{equation*}$$ can be derived directly from a stationary action principle?

Clearly, if $$\gamma$$ does not depend on the position, then the time-dependent damped Lagrangian $$\mathcal{L}(x,\dot{x},t)=e^{\gamma t}(\dot{x}^{2}-\omega_{0}^{2}x^{2})/2\tag{2}$$ would do the job.

Concerning a non-variational Lagrangian formulation, the above equation (1) can be derived by introducing the Rayleigh dissipation function $$Q(x,\dot{x})=-\frac{\partial\mathcal{F}}{\partial\dot{x}},\tag{3}$$ where $$\mathcal{F}(x,\dot{x})=\frac{1}{2}\gamma(x)\dot{x}^{2}.\tag{4}$$ However, does there exist a stationary action principle for equation (1)?

TL;DR: Yes, a variational formulation/stationary action principle exists locally if the variable $$x$$ is 1-dimensional (rather than multi-dimensional).

One can rewrite any second-order ODE (such as OP's eom) as 2 coupled first-order OPEs $$\dot{x}~=~f(x,y), \qquad \dot{y}~=~g(x,y).\tag{A}$$ More generally, a variational formulation exists locally for any system of the form (A).

Sketched existence proof:

1. It is explained in my Phys.SE answer here that there exists locally a Hamiltonian formulation $$\dot{x}~=~\{x,H\}, \qquad \dot{y}~=~\{y,H\}\tag{B}$$ of the system (A).

2. A Poisson structure in 2 dimensions is fully determined by a single function $$B(x,y)~:=~\{x,y\}.\tag{C}$$

3. The corresponding symplectic 2-form $$\omega~=~\frac{1}{B}\mathrm{d}y\wedge \mathrm{d}x~=~\mathrm{d}\theta\tag{D}$$ is locally exact, where $$\theta~=~a(x,y)~\mathrm{d}x+b(x,y)~\mathrm{d}y\tag{E}$$ is a symplectic potential 1-form.

4. The Hamilton's equations (B) are the Euler-Lagrange (EL) equations of the following Hamiltonian Lagrangian: $$L_H~:=~a\dot{x}+b\dot{y}-H . \tag{F}$$

5. The corresponding action is $$S_H~=~\int \! dt~L_H. \tag{G}$$ $$\Box$$

Note that the Lagrangian (F) does not depend explicitly on time unlike eq. (2).