Find an function that oscillates between a given upper and lower envelope Suppose I'm given two real, continuous functions $f(x)$ and $g(x)$ such that $f(x)\ge g(x)$ for all real $x$. I'd like to determine an oscillating function $h(x)$ that has $f(x)$ as its upper-envelope and $g(x)$ as its lower envelope. The following image comes from the Wikipedia page titled "Envelope (waves)".

I'm interested in an open form for the blue function. Thanks for any references or help.

One possibility is
$$
h(x) = (\sin^2 x) f(x) + (1 - \sin^2 x) g(x).
$$
The function $\sin^2 x$ oscillates between $0$ and $1$, reaching
each extreme once per cycle;
$h(x)$ uses $\sin^2 x$ to interpolate between $f(x)$ and $g(x)$,
so when $\sin^2 x = 0$, $h(x) = g(x)$,
but when $\sin^2 x = 1$, $h(x) = f(x)$.
