Solution (source code)

= Solution

Introduce the <slow time> $T=\epsilon t$ and use the <method of multiple scales> with $x_0=A(T)\cos\psi$, $\psi=t+\theta(T)$. The initial data give $A(0)=\sqrt2$ and $\theta(0)=-\pi/4$. At first order the equation for the correction is
$$
x_{1,tt}+x_1=2A'\sin\psi+2A\theta'\cos\psi+A f(A\cos\psi)\sin\psi.
$$
The <averaged amplitude for position-dependent damping> follows from the <solvability condition in the method of multiple scales>, which removes the resonant sine and cosine terms. With brackets denoting a full-period average, this gives
$$
A'=-A\langle f(A\cos\psi)\sin^2\psi\rangle,\qquad\theta'=0.
$$
The <wave phase> average vanishes because $f(A\cos\psi)\sin\psi\cos\psi$ changes sign under $\psi\mapsto2\pi-\psi$.

For the quadratic <position-dependent damping>, $\langle\cos^2\psi\sin^2\psi\rangle=1/8$ and $\langle\sin^2\psi\rangle=1/2$, so
$$
A'=\frac A2-\frac{A^3}8,\qquad (A^2)'=A^2-\frac{A^4}4.
$$
Solving this <logistic equation> with $A^2(0)=2$ gives $A(T)=2/\sqrt{1+e^{-T}}$. Thus \b[the uniformly valid leading approximation is]
$$
\boxed{x(t;\epsilon)=\frac{2\cos(t-\pi/4)}{\sqrt{1+e^{-\epsilon t}}}+O(\epsilon),
\qquad0\leq t\leq T_*/\epsilon.}
$$
Here $T_*$ is any fixed finite positive constant. Bounded nonresonant corrections and the averaging estimate make the error uniform on this slow-time interval. The leading expression meets the position datum exactly and the velocity datum to leading order; the first-order correction supplies its $O(\epsilon)$ adjustment.