6
$\begingroup$

I have the following function:

$$ f(q,y)= \begin{cases} \tfrac{11720+p}{37791360} & -11720<p<-7720 \\ 0 & \text{True} \end{cases} $$

where $p = 443\ y-777600\ \sin^{-1}\left(\frac{q \lambda }{4 \pi }\right)$.

Mathematica Code:

f[q_,y_]=Piecewise[ {{(11720+443 y-777600 ArcSin[(q λ)/(4 π)])/37791360, -11720<443 y-777600 ArcSin[(q λ)/(4 π)]<-7720}}, 0] 

Now, if I take an indefinite integral over y,

weird[q_, y_] = Integrate[f[q, y], y] 

which gives

$$ g(q,y)= \begin{cases} \frac{293 y}{944784}+\frac{443 y^2}{75582720}-\frac{5}{243} y\ \sin^{-1}\left(\frac{\text{qy} \lambda }{4 \pi }\right) & -11720<p<-7720 \\ 0 & \text{True} \end{cases} $$

I can then evaluate this function at my endpoints {-1,1} to get the definite integral.

However, I could also have Mathematica run the definite integral directly.

weirder[q_, y_] = Integrate[f[q, y], {y, -1, 1}] 

which gives

something really big

Plain Text Version:

\[Piecewise] (293-19440 ArcSin[(q \[Lambda])/(4 \[Pi])])/472392 907/86400<ArcSin[(q \[Lambda])/(4 \[Pi])]<=1253/86400 (1/33483144960)(-111170729+29544134400 ArcSin[(q \[Lambda])/(4 \[Pi])]-1209323520000 ArcSin[(q \[Lambda])/(4 \[Pi])]^2-12006144000 I Log[4 \[Pi]]-604661760000 Log[4 \[Pi]]^2+12006144000 I Log[I q \[Lambda]+Sqrt[16 \[Pi]^2-q^2 \[Lambda]^2]]+1209323520000 Log[4 \[Pi]] Log[I q \[Lambda]+Sqrt[16 \[Pi]^2-q^2 \[Lambda]^2]]-604661760000 Log[I q \[Lambda]+Sqrt[16 \[Pi]^2-q^2 \[Lambda]^2]]^2) 7277/777600<ArcSin[(q \[Lambda])/(4 \[Pi])]<=907/86400 (1/33483144960)(147938569-37142841600 ArcSin[(q \[Lambda])/(4 \[Pi])]+1209323520000 ArcSin[(q \[Lambda])/(4 \[Pi])]^2+18226944000 I Log[4 \[Pi]]+604661760000 Log[4 \[Pi]]^2-18226944000 I Log[I q \[Lambda]+Sqrt[16 \[Pi]^2-q^2 \[Lambda]^2]]-1209323520000 Log[4 \[Pi]] Log[I q \[Lambda]+Sqrt[16 \[Pi]^2-q^2 \[Lambda]^2]]+604661760000 Log[I q \[Lambda]+Sqrt[16 \[Pi]^2-q^2 \[Lambda]^2]]^2) 1253/86400<ArcSin[(q \[Lambda])/(4 \[Pi])]<12163/777600 0 True 

This result, depending on my value of q, is different that the result given by the indefinite integral. Specifically of note are the log terms, which did not appear in the indefinite integral.

Why is the definite integral different from subtracting the end points of the indefinite integral? Which of these results should I trust?

$\endgroup$
2
  • $\begingroup$ Can you give a value of $q$ and $\lambda$ that actually give a different numerical result? $\endgroup$ Commented Feb 24, 2012 at 1:35
  • 12
    $\begingroup$ When the indefinite integral has discontunities, substituting the endpoints in the indefinite integral expression gives incorrect results. You get the correct result for the definite integral. Check the section Possible Issues subsection Definite Integral under Integrate in documentation. $\endgroup$ Commented Feb 24, 2012 at 2:05

1 Answer 1

12
$\begingroup$

When the indefinite integral has discontunities (as is the case for your integrand for some values of q and alpha), substituting the endpoints in the indefinite integral expression gives incorrect results. To get the correct result you need to use the definite integral.

Please see the section Possible Issues subsection Definite Integral under Integrate in docs. The issue is also discussed at length in this Wolfram Blog entry: Mathematica and the Fundamental Theorem of Calculus.

$\endgroup$
3
  • 1
    $\begingroup$ A particularly nasty example is $$\int^\infty_0 \frac{e^{−x}}{\sin x}dx$$ which is discussed here. Of particular relevance is this answer which discusses how the changing the limits effected the outcome. $\endgroup$ Commented Mar 2, 2012 at 19:37
  • $\begingroup$ I used this question as a duplicate target, so I added a references to your answer pointing to a wolfram blog entry on the same issue. Please feel free to revert the change if you find it inappropriate, $\endgroup$ Commented Jul 10, 2018 at 22:59
  • $\begingroup$ Thank you @MarcoB. $\endgroup$ Commented Jul 10, 2018 at 23:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.