# plotting a trig functions along with its envelope

Note: This questions is quite different from the ones referred to in the comments. Those deal with numerical questions, while this one is algebraic.

I have plots of the following type:

Plot[Cos[50 t] + Cos[51 t], {t, 0, 10}] I would like to plot a envelope over this plot, i.e. another plot that joins all of maxima and minima of this plot respectively. Here is my attempt, but it's not exactly what I'd like:

Plot[{Cos[50 t] + Cos[51 t], Cos[t] + 1.5, -Cos[t] - 1.5}, {t, 0, 10}] How can I generate the actual envelope?

• I'm guessing that's something like Cos[42x]+Cos[43x]? – Mark McClure Jun 3 '14 at 18:29
• this is completely true but this is for the Fig.1, I want to access to sheath while I do not access to any formula for that. – Unbelievable Jun 3 '14 at 18:32
• Well, you've got to give us some kind of input to start with. – Mark McClure Jun 3 '14 at 18:34
• I plotted these ones with: Plot[{Cos[50 t] + Cos[51 t], Cos[t] + 1.5, -Cos[t] - 1.5}, {t, 0, 10}], I used of simulated functions 'Cos[t] + 1.5' and '-Cos[t] - 1.5' for the sheath. – Unbelievable Jun 3 '14 at 18:36
• Nearly a duplicate of Elegant way of obtaining the envelope of oscillating function, which is a duplicate of Mathematica envelope for the bottom of a plot, a generic function. But this one just straight trigonometry. – Michael E2 Aug 28 '14 at 0:20

Playing with the manipulate below might help. It's based on the the acoustics of beats.

Manipulate[Plot[
{Cos[a*t] + Cos[b*t], 2*Cos[(b - a) t/2], -2*Cos[(b - a) t/2]}, {t, 0, 10},
PlotStyle -> {
Directive[Opacity[0.7]],
Directive[Black, Thick],
Directive[Black, Thick]}],
{{a, 20}, 1, 50}, {{b, 21}, 1, 50}] • Thank you so much. this is correct – Unbelievable Jun 3 '14 at 18:58

Don't mind me, I'm just having fun.

Grab the definition of HilbertTransform from this previous post, and then:

f[t_] := Cos[50 t] + Cos[51 t] + Sin[53 t] (* more sinusoids = more fun *)
g[t_] := Evaluate@HilbertTransform[f[τ], τ, t]
h[t_] := Abs[f[t] + I g[t]]
Plot[{f[t], h[t], -h[t]}, {t, 0, 10}, ImageSize -> Large, PlotPoints -> 100,
PlotStyle -> {Automatic, Black, Black}] You can see that the envelope has a nice analytical form:

ComplexExpand[h[t]] // FullSimplify


$\sqrt{3 + 2\cos t + 2\sin 2t + 2\sin 3t}$