# What is going on in this plot?

Plot[{ArgMax[Cos[t] Sinc[2*Pi kl (Sin[t] - 1/Sqrt)], t]*180/Pi,
45}, {kl, 0, 10}, PlotRange -> Full] I want to know what causes this, and how to fix it in case it happens in the future.

• You can investigate this, for example, by looking at ContourPlot[Cos[t] Sinc[2 Pi kl (Sin[t] - 1/Sqrt)], {kl, 4, 6}, {t, -8, 8}, PlotRange -> All]. It seems pretty nasty... – kirma Apr 8 '16 at 11:11

As noted by kirma, this function is highly oscillatory. However, from its form it is periodic in t with period 2 Pi and has its maximum near Pi/4 except for small kl. For instance,

Plot[Evaluate[Cos[t] Sinc[2 Pi kl (Sin[t] - 1/Sqrt)] /.
kl -> Range[0, 2, 1/2]], {t, 0, 2 Pi}, PlotRange -> All] Because ArgMax sometimes finds a local maximum instead of the global maximum, we can help it by adding a constraint that takes advantage of the fact (just shown) that the maximum lies between 0 and Pi/4.

Plot[{ArgMax[{Cos[t] Sinc[2*Pi kl (Sin[t] - 1/Sqrt)],
0 < t < Pi/2}, t]*180/Pi, 45}, {kl, 0, 10}, PlotRange -> Full] as desired.