Artificial intelligent assistant

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.

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

![Envelope_SineWave](

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

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 3d392357002df169ae1ac8ee453c1a46