# Plot of integral of summed Sinc series is incorrect

I have curve given by summing a small, finite series of Sinc functions, and I want to plot both the curve and its integral. In principle, it's easy:

test[x_] := Sinc[Pi*x]^2 + Sinc[Pi*(x - 3)]^2 + Sinc[Pi*(x - 6)]^2 +
Sinc[Pi*(x - 9)]^2 + Sinc[Pi*(x - 12)]^2 + Sinc[Pi*(x - 15)]^2;
sumtest = Integrate[test[x], x];
Plot[{test[x], sumtest}, {x, 0, 15}, PlotLegends -> "Expressions"]

...but in practice, it's not working. Since the Sinc functions are all squared, the curve is necessarily positive at all points for real x. Therefore, the integral is also always positive. But my plot looks like this:

Can someone tell me what I'm doing wrong - and how to do it right?

• Integrate[test[x], x] will give you only one of many possible antiderivatives, and not necessarily the one you want. You need an extra condition that will impose your positivity requirement. – J. M. is in limbo Sep 24 '18 at 12:19
• OK. How do I do that? – Richard Burke-Ward Sep 24 '18 at 12:21
• You seem to be starting from $0$, so try subtracting the result of Limit[Integrate[test[x], x], x -> 0] to your integral. – J. M. is in limbo Sep 24 '18 at 12:23
• Exactly what I needed. Thank you. Want to promote your response to 'answer' so I can tick it? – Richard Burke-Ward Sep 24 '18 at 12:27
• If I may: if you understand what Limit[Integrate[test[x], x], x -> 0] was supposed to compute, I encourage you to try writing an answer to your own question. :) I can then refine it if needed and maybe even upvote it. – J. M. is in limbo Sep 24 '18 at 12:29

Thanks to the generous input of @J.M. is somewhat okay, here is the answer:

I got mixed between definite and indefinite integrals (or antiderivatives). As a result, I wrote a formula that gave the generalised integral (antiderivative) rather than the partial integral specifically between x=0 and the end-point of the plot at x=15. I didn't spot that I'd made this assumption - and MMA, faced with an infinite range of equally valid assumptions about what constant to add to the antiderivative, chose a different number.

Subtracting a Limit[] as x->0 corrects for this:

test[x_] := Sinc[Pi*x]^2 + Sinc[Pi*(x - 3)]^2 + Sinc[Pi*(x - 6)]^2 +
Sinc[Pi*(x - 9)]^2 + Sinc[Pi*(x - 12)]^2 + Sinc[Pi*(x - 15)]^2;
sumtest = Integrate[test[x], x]-Limit[Integrate[test[x], x], x -> 0];
Plot[{test[x], sumtest}, {x, 0, 15}, PlotLegends -> "Expressions"]

• Very minor nit: Integrate[] happened to give one possible antiderivative among infinitely many choices. Or put differently: Integrate[] gave you an antiderivative, but not the one you wanted where $F(0)=0$. – J. M. is in limbo Sep 24 '18 at 13:02
• Noted and changed. Thanks JM :-) – Richard Burke-Ward Sep 24 '18 at 13:17
• Or use sumtest[x_] = Assuming[x > 0, Integrate[test[t], {t, 0, x}]] – Bob Hanlon Sep 25 '18 at 3:27