What function $f(x,t)$ could be used to describe the purple curve in this animation Here is the gif
I stumbled across this by accident and have become intrigued by it. The key point is that the purple curve is always tangential to the two other curves (3/2 * cos(x) + 3 and -3/2 * cos(x) - 3) at two points separated by an x distance of 2. If you would like to change the two starting curves to avoid the awkward y-axis intervals and the non-pi multiples on the x-axis then that is fine.
All I can do is guess work and trial and error since I've never seen a method for solving problems like these so hopefully someone has a solution to give an exact answer in a bit more contrived way.
 A: I have found a family of curves $C_a$ (where $a$ is a parameter) with equations:
$$\tag{1}y=f_a(x)=(3+(3/2)\sin(a))\sin(x-a)$$
As $a$ varies, the snake-like movement of these curves is like on the video. 

Moreover the locus of maximum (resp. minimal) points of curves $f_a$ is exactly curve $y=3/2\cos(x)+3$ (resp. $y=-3/2\cos(x)+3$). 

BUT the (double) envelope of the family is constituted by curves that are close to curves $y=\pm3/2\cos(x)+3$, but cannot be pure sinusoids, as has been remarked by @Narasimham (too spiky).
Remark: I have attempted to obtain an implicit or parametric expression of the envelope by the classical technique (elimination of parameter $a$ between expression (1) and its derivative with respect to $a$). But I have not obtained significant results. 
A: HINT
If the envelope is known, one way is by taking $y$ in form
$$ y = f(t) \sin ( x +t) \tag {1} $$
To obtain singular solution we can use $C-$ discriminant method starting by partially differentiating above w.r.t.$t$ 
$$  f'(t) \sin ( x +t) +f(t) \cos ( x +t)  =0 \tag {2} $$
and eliminating $t$ between (1,2), equate the eliminant to given envelope/singular solution to find an $f$. As the envelope is not fully given, some connecting guessing  is needed.
EDIT1:
If you are comfortable with Mathematica an animation of one solution set (from anderstood,corey979 yesterday to my query at the SE site) results from:
Clear[a]; f[x_, a_] = Cos[x + a] + Cos[x]^2;
plots = Table[
   Plot[f[x, a], {x, 0, 2 Pi}, PlotRange -> {-1, 2}], {a, -4, 4, .5}];
frames = FoldList[Show, First@plots, Rest@plots];
ListAnimate[frames, AnimationRate -> 4]

Animation_of_Trig_function

However needs more guessing/playing with $ f(x,a). $ 
