Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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}]

enter image description here

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}]

enter image description here

How can I generate the actual envelope?

share|improve this question
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. –  mr.0093 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. –  mr.0093 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

2 Answers 2

up vote 11 down vote accepted

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

  {Cos[a*t] + Cos[b*t], 2*Cos[(b - a) t/2], -2*Cos[(b - a) t/2]}, {t, 0, 10},
  PlotStyle -> {
   Directive[Black, Thick], 
   Directive[Black, Thick]}],
 {{a, 20}, 1, 50}, {{b, 21}, 1, 50}]

enter image description here

share|improve this answer
Thank you so much. this is correct –  mr.0093 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}]

enter image description here

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}$

Further reading: analytic representation.

share|improve this answer
This way though doesn't seem to catch when the envelope should go to zero. Shouldn't it e.g. vanish near 2? –  Ruslan Jun 4 '14 at 8:34
Should it? It still looks like a sinusoid with small but nonzero amplitude there. (The envelope correctly goes to zero for the original function in the question, if that's what you're concerned about.) –  Rahul Jun 4 '14 at 8:55
Ah, OK then, you're right. –  Ruslan Jun 4 '14 at 9:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.