Plot of integral of summed `Sinc` series is incorrect

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












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:



<code>Sinc^2</code> in blue, integral in orange



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










share|improve this question























  • 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 somewhat okay.♦
    1 hour ago










  • OK. How do I do that?
    – Richard Burke-Ward
    1 hour ago










  • 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 somewhat okay.♦
    1 hour ago










  • Exactly what I needed. Thank you. Want to promote your response to 'answer' so I can tick it?
    – Richard Burke-Ward
    1 hour ago










  • 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 somewhat okay.♦
    1 hour ago














up vote
1
down vote

favorite












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:



<code>Sinc^2</code> in blue, integral in orange



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










share|improve this question























  • 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 somewhat okay.♦
    1 hour ago










  • OK. How do I do that?
    – Richard Burke-Ward
    1 hour ago










  • 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 somewhat okay.♦
    1 hour ago










  • Exactly what I needed. Thank you. Want to promote your response to 'answer' so I can tick it?
    – Richard Burke-Ward
    1 hour ago










  • 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 somewhat okay.♦
    1 hour ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











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:



<code>Sinc^2</code> in blue, integral in orange



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










share|improve this question















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:



<code>Sinc^2</code> in blue, integral in orange



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







plotting calculus-and-analysis trigonometry






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









J. M. is somewhat okay.♦

92.5k10286440




92.5k10286440










asked 1 hour ago









Richard Burke-Ward

3738




3738











  • 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 somewhat okay.♦
    1 hour ago










  • OK. How do I do that?
    – Richard Burke-Ward
    1 hour ago










  • 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 somewhat okay.♦
    1 hour ago










  • Exactly what I needed. Thank you. Want to promote your response to 'answer' so I can tick it?
    – Richard Burke-Ward
    1 hour ago










  • 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 somewhat okay.♦
    1 hour ago
















  • 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 somewhat okay.♦
    1 hour ago










  • OK. How do I do that?
    – Richard Burke-Ward
    1 hour ago










  • 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 somewhat okay.♦
    1 hour ago










  • Exactly what I needed. Thank you. Want to promote your response to 'answer' so I can tick it?
    – Richard Burke-Ward
    1 hour ago










  • 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 somewhat okay.♦
    1 hour ago















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 somewhat okay.♦
1 hour ago




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 somewhat okay.♦
1 hour ago












OK. How do I do that?
– Richard Burke-Ward
1 hour ago




OK. How do I do that?
– Richard Burke-Ward
1 hour ago












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 somewhat okay.♦
1 hour ago




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 somewhat okay.♦
1 hour ago












Exactly what I needed. Thank you. Want to promote your response to 'answer' so I can tick it?
– Richard Burke-Ward
1 hour ago




Exactly what I needed. Thank you. Want to promote your response to 'answer' so I can tick it?
– Richard Burke-Ward
1 hour ago












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 somewhat okay.♦
1 hour ago




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 somewhat okay.♦
1 hour ago










1 Answer
1






active

oldest

votes

















up vote
2
down vote













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


enter image description here






share|improve this answer






















  • 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 somewhat okay.♦
    55 mins ago










  • Noted and changed. Thanks JM :-)
    – Richard Burke-Ward
    40 mins ago










Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182463%2fplot-of-integral-of-summed-sinc-series-is-incorrect%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













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


enter image description here






share|improve this answer






















  • 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 somewhat okay.♦
    55 mins ago










  • Noted and changed. Thanks JM :-)
    – Richard Burke-Ward
    40 mins ago














up vote
2
down vote













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


enter image description here






share|improve this answer






















  • 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 somewhat okay.♦
    55 mins ago










  • Noted and changed. Thanks JM :-)
    – Richard Burke-Ward
    40 mins ago












up vote
2
down vote










up vote
2
down vote









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


enter image description here






share|improve this answer














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


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 42 mins ago

























answered 59 mins ago









Richard Burke-Ward

3738




3738











  • 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 somewhat okay.♦
    55 mins ago










  • Noted and changed. Thanks JM :-)
    – Richard Burke-Ward
    40 mins ago
















  • 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 somewhat okay.♦
    55 mins ago










  • Noted and changed. Thanks JM :-)
    – Richard Burke-Ward
    40 mins ago















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 somewhat okay.♦
55 mins ago




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 somewhat okay.♦
55 mins ago












Noted and changed. Thanks JM :-)
– Richard Burke-Ward
40 mins ago




Noted and changed. Thanks JM :-)
– Richard Burke-Ward
40 mins ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182463%2fplot-of-integral-of-summed-sinc-series-is-incorrect%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

List of Gilmore Girls characters

One-line joke