Generally to be sure to get an accurate graph you should aim to have the initial sampling have at least one point in each pit and on each peak (or more precisely in each concave up segment and each concave down segment). Strictly speaking it is not necessary to hit every one because of the way Plot
works, but it is sufficient. Then the recursive subdivision algorithm of Plot
will reveal the features of the graph.
Your function has a spike at t = 1, 2,..., 120
. So 241 points at roughly t = 0.0, 0.5, 1.0, 1.5,..., 120.0
should work. I say roughly, because Plot
does an asymmetric subdivision. The distance between successive points will be approximately 0.5
, but since the spikes are narrow, it is conceivable that some might be missed. (But it turns out that they are not. In fact, 121 or even 61 plot points works in this case, but not 62 and not 31.)
Plot[\[Theta]z[t], {t, 0, 120}, PlotPoints -> 121, PlotRange -> All,
MaxRecursion -> 9, ImageSize -> Medium] // AbsoluteTiming

You'll notice some warning/error messages. That's what I get pasting your definition from the OP into Mathematica. If I convert it to InputForm
, the messages go away, but it's quite a bit slower!

A faster way to compute your function on floating-point input is the following:
θz[t_?NumericQ] := Total[E^(- (t - Range[120])^2/(4 ϵ))/(2 Sqrt[ϵ*π])];
Plot[θz[t], {t, 0, 120}, PlotPoints -> 121, PlotRange -> All,
MaxRecursion -> 9, ImageSize -> Medium] // AbsoluteTiming

Plot
sampling too coarsely when plotting. If you plot with the commandPlot[\[Theta]z[t], {t, 0, 120}, PlotRange -> All, MaxRecursion -> 10]
, you will see more spikes and they are the same height, but still a lot will be missing. Increasing further will take more time and hopefully show more spikes. AddingPlotPoints -> 100
or something should also help. But there is nothing wrong with your function, so don't worry :) $\endgroup$ – Marius Ladegård Meyer Jul 30 '18 at 11:38