Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Definite Integration in Mathematica

257 views
Skip to first unread message

dimitris

unread,
Mar 21, 2007, 3:50:07 AM3/21/07
to
Hello to all of you!

Firstly, I apologize for the lengthy post!
Secondly, this post has a close connection with a recent (and well
active!)
thread titled "Integrate" and one old post of mine which was based on
a older
post of David Cantrell. Since there was no response and I do consider
the
subject very fundamental I would like any kind of insight.

In the section about Proper Integrals in his article, Adamchik
mentions that the Newton-Leibniz formula (i.e. the Fundamental
Theorem of Integral Calculus: Integrate[f[x],{x,a,b}]=F[b]-F[a],
F[x]: an antiderivative), does not hold any longer if the
antiderivative F(x) has singularities in the integration interval
(a,b).

To demonstrate this, he considers the integral of the function:

f[x_] = (x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17);

over the interval (0,4).

Plot[f[x], {x, 0, 4}];
(*plot to be displayed*)

The integrand posseses no singularities on the interval (0,4).

Here is the corresponding indefinite integral

F[x_] = Simplify[Integrate[f[x], x]]
ArcTan[(1 + x)/(4 - x^2)]

Substituting limits of integration into F[x] yields an incorrect
result

Limit[F[x], x -> 4, Direction -> 1] - Limit[F[x], x -> 0, Direction -
>1]
N[%]
NIntegrate[f[x], {x, 0, 4}]

-ArcTan[1/4] - ArcTan[5/12]
-0.6397697828266257
2.501822870767894

This is because the antiderivative has a jump discontinuity at x=2
(also at x = -2), so that the Fundamental theorem cannot be used.

Indeed

Limit[F[x], x -> 2, Direction -> #1]&/@{-1, 1}
Show@Block[{$DisplayFunction=Identity},
Plot[F[x],{x,#[[1]],#[[2]]}]&/@Partition[Range[0,4,2],2,1]];
{-(Pi/2), Pi/2}
(*plot to be displayed*)

The right way of applying the Fundamental theorem is the following

(Limit[F[x], x -> 4, Direction -> 1] - Limit[F[x], x -> 2, Direction -
> -1]) +
(Limit[F[x], x -> 2, Direction -> 1] - Limit[F[x], x -> 0, Direction
-> -1])
N[%]
Pi - ArcTan[1/4] - ArcTan[5/12]
2.501822870763167

Integrate works in precisely this way

Integrate[f[x], {x, 0, 4}]
N[%]

Pi - ArcTan[1/4] - ArcTan[5/12]
2.501822870763167

A little later, he (i.e. Adamchik) says "The origin of
discontinuities
along the path of integration is not in the method of indefinite
integration but rather in the integrand."

Adamchik mentions next that the four zeros of the integrand's
denominator
are two complex-conjugate pairs having real parts +/- 1.95334. It
then
seems that he is saying that, connecting these conjugate pairs by
vertical line segments in the complex plane, we get two branch
cuts...

BUT didn't the relevant branch cuts for his int cross the real axis
at x = +/- 2, rather than at x = +/- 1.95334?

(NOTE: The difference between 1.95334 and 2 is not due to numerical
error).

Exactly what's going on here?

Show[GraphicsArray[Block[{$DisplayFunction = Identity},
(ContourPlot[#1[F[x + I*y]], {x, -4, 4}, {y, -4, 4}, Contours -> 50,
PlotPoints -> 50, ContourShading -> False, Epilog -> {Blue,
AbsoluteThickness[2], Line[{{0, 0}, {4, 0}}]},
PlotLabel -> #1[HoldForm[F[x]]]] & ) /@ {Re, Im}]], ImageSize
- > 500];
(*contour plots to be displayed*)


Consider next the following function

f[x_] = 1/(5 + Cos[x]);

Then

Integrate[f[x], {x, 0, 4*Pi}]
N[%]
NIntegrate[f[x], {x, 0, 4*Pi}]

Sqrt[2/3]*Pi
2.565099660323728
2.5650996603270704

F[x_] = Integrate[f[x], x]
ArcTan[Sqrt[2/3]*Tan[x/2]]/Sqrt[6]

D[F[x], x]==f[x]//Simplify
True

Plot[f[x], {x, 0, 4*Pi}, Ticks -> {Range[0, 4*Pi, Pi/2], Automatic}]
Plot[F[x], {x, 0, 4*Pi}, Ticks -> {Range[0, 4*Pi, Pi/2], Automatic}]

The antiderivative has jump discontinuities at Pi and 3Pi inside the
integration range

Table[(Limit[F[x], x -> n*(Pi/2), Direction -> #1] & ) /@ {-1, 1}, {n,
0, 4}]
{{0, 0}, {ArcTan[Sqrt[2/3]]/Sqrt[6], ArcTan[Sqrt[2/3]]/Sqrt[6]}, {-(Pi/
(2*Sqrt[6])), Pi/(2*Sqrt[6])},
{-(ArcTan[Sqrt[2/3]]/Sqrt[6]), -(ArcTan[Sqrt[2/3]]/Sqrt[6])}, {0,
0}}

Reduce[5 + Cos[x] == 0 && 0 <= Re[x] <= 4*Pi, x]
{ToRules[%]} /. (x_ -> b_) :> x -> ComplexExpand[b]
x /. %;
({Re[#1], Im[#1]} & ) /@ %;
poi = Point /@ %;

x == 2*Pi - ArcCos[-5] || x == 4*Pi - ArcCos[-5] || x == ArcCos[-5] ||
x == 2*Pi + ArcCos[-5]
{{x -> Pi - I*Log[5 - 2*Sqrt[6]]}, {x -> 3*Pi - I*Log[5 - 2*Sqrt[6]]},
{x -> Pi + I*Log[5 - 2*Sqrt[6]]},
{x -> 3*Pi + I*Log[5 - 2*Sqrt[6]]}}

Of course F[4Pi]-F[0]=0 incorrectly.

The reason for the discrepancy in the above result is not because of
any problem with the fundamental theorem of calculus, of course; it is
caused by the multivalued nature of the indefinite integral arctan.


Show[GraphicsArray[Block[{$DisplayFunction = Identity},
(ContourPlot[#1[F[x + I*y]], {x, 0, 4*Pi}, {y, -4, 4}, Contours ->
50, PlotPoints -> 50, ContourShading -> False,
FrameTicks -> {Range[0, 4*Pi, Pi], Automatic, None, None},
Epilog -> {{PointSize[0.03], Red, poi},
{Blue, Line[{{0, 0}, {4*Pi, 0}}]}}] & ) /@ {Re, Im}]],
ImageSize -> 500]

So, in this example the discontinuities are indeed from the branch
cuts that start and end from the simple poles of the integrand which
is in agreement with V.A. paper!


I think I am not aware of something fundamental!
Can someone point out what I miss?


Regards
Dimitris


dimitris

unread,
Mar 22, 2007, 2:09:10 AM3/22/07
to

Hello Daniel!

Of course I am aware of branch cuts and the stuff!

May be I was not too clear in order someone to understand me!

Read the first 4 pages of the paper of V Adamichik's Definite
Integration
in Mathematica v. 3.0. available from here:

http://library.wolfram.com/infocenter/Articles/3157/

I will try to set my question as clear as I can!

The integral that appears in V.A. paper is

f = HoldForm[Integrate[(4 + 2*x + x^2)/(17 + 2*x - 7*x^2 + x^4), {x,
0, 4}]]

and the integrand is a smooth integrable function in the whole real
axis.

Mathematica's answer of (symbolic) definite integration is

ReleaseHold@%


Pi - ArcTan[1/4] - ArcTan[5/12]

which agrees with the result obtained by numerical integration

{(N[#1, 20] & )[%], ReleaseHold[f /. Integrate[x___] :> NIntegrate[x,
WorkingPrecision -> 40,
AccuracyGoal -> 20]]}
{2.5018228707631675676, 2.50182287076316756755}

Everything is ok up to now! And as I have shown in an old post you can
using Mathematica to get a continuus
antiderivative in the integration range but this is not my goal! I am
very happy by Mathematica's antiderivative which is rather simple
contrary to my expression.

Mathematica uses (an extended version of) Risch algorithm in order to
get an antiderivative
for [(x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17)

Simplify[Integrate[(x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17), x]]


ArcTan[(1 + x)/(4 - x^2)]

and due to the jump discontinuity of ArcTan at x=2 the correct way in
order to apply the Newton-Leibniz formula
is

(% /. x -> 4) - Limit[%, x -> 2, Direction -> -1] + Limit[%, x -> 2,
Direction -> 1] - (% /. x -> 0)


Pi - ArcTan[1/4] - ArcTan[5/12]

Again everything is clear and absolutely easy to understand!

My query appears exactly after this point!

Victor Adamchik tries next (in the same article) to explain the
situation.

He states that discontinuities of antiderivatives along the path of
integration are due to the nature of the integrand-not the method of
indefinite integration. In the above example, the integrand has four
singular poles that become branch points for the antiderivative.
Connected in pairs these points make two branch cuts. The path of
integration crosses one of them

The poles of the integrand are at the following points in the complex
plain

NSolve[x^4 - 7*x^2 + 2*x + 17 == 0, x]
{{x -> -1.9533360788744223 - 0.2440276635405635*I}, {x ->
-1.9533360788744223 + 0.2440276635405635*I},
{x -> 1.9533360788744223 - 0.7559723364594371*I}, {x ->
1.9533360788744223 + 0.7559723364594371*I}}

(ContourPlot[Evaluate[#1[ArcTan[(1 + x)/(4 - x^2)] /. x -> x + I*y]],
{x, -3, 4}, {y, -3, 4}, ContourShading -> False,
Contours -> 20, PlotPoints -> 40, Epilog -> {Hue[0],
Thickness[0.005], Line[{{0, 0}, {4, 0}}]}] & ) /@ {Re, Im}

What I don't understand is exactly his statement "... Connected in
pairs these points make two branch cuts..."
and how is connected with the jump discontinuity at x=2.

These pairs of chosen branch cuts by Mathematica for the
antiderivative cross the horizontal axis at x=+/-2?

If the answer is yes at last I have understand it!


dh <d...@metrohm.ch> wrote:

Hi Dimitris,
if an anylytic function is multivalued with singularities, people
often
try nevertheless to define a continuous single valued function. This
is
not possible globally, there are always places where we will have a
misfit. One therefore cuts the plane and defines "branch cuts" where
the
new function is not continuous. Away from these cuts the function is
continuous. Note that these cuts are not clear cut. As long as we get
a
continuos function, we can choose the cuts as we please. Further, as
the
original function is multivalued, we can define even more different
continuous functions.
Now concerning the fundmental theorem, it seems clear that if we
cross
the branch cut the theorem can not be applied. It only works if the
antiderivative is continuous in the integration range. In your case:
ArcTan[(1 + x)/(4 - x^2)], the branch cut was chosen so that we have
a
discontinuity at x=2. If we had chosen the branch cuts differently,
we
may have been able to find a function that is continuous in 0..4. But
this is not easily done! At least not analytically. However, you may
easily do so numerically in the real domain (although the function
may
not be non-analytical (no power series)).
Daniel

Michael Weyrauch

unread,
Mar 22, 2007, 2:18:28 AM3/22/07
to
Hello,

another nice example, where the result for the integral given by Mathematica just
cannot be right. The indefinite integral of a continuuos function cannot have a jump.
That -- to my opinion -- is mathematical nonsens. We all learned that integration "smoothens",
i.e. if the integrand is somewhat "ugly" the integral is less "ugly". (Never mind my English!).

So the result should actually be presented as

F[x_]=ArcTan[(1 + x)/(4 - x^2)]*UnitStep[2 - x] +
(Pi + ArcTan[(1 + x)/(4 - x^2)])*UnitStep[-2 + x]

This is a perfectly nice function without jumps and it is the antiderivative of your integrand,
and the fundamental theorem of calculus works with it...

So, despite my love for Mathematica, here it fools me....

Regards Michael


"dimitris" <dimm...@yahoo.com> schrieb im Newsbeitrag news:etqo3f$10i$1...@smc.vnet.net...

dimitris

unread,
Mar 22, 2007, 2:24:36 AM3/22/07
to
And here is one case that evaluating first the indefinite integral and
then
apply the Newton-Leibniz formula is preferable than trust Definite
Integration
capabillities of Mathematica

Integrate[(2 - Sin[x])^(1/4), {x, 1, 4}]
N[%]
Integrate[(2 - Sin[x])^(1/4), x]
Simplify[Limit[%, x -> 4, Direction -> 1] - Limit[%, x -> 1, Direction
-> -1]]
Chop[N[%]]
NIntegrate[(2 - Sin[x])^(1/4), {x, 1, Pi/2, 4}]

-((1/
(5*Sqrt[3]*Gamma[7/4]))*(2*I*(5*Sqrt[Pi]*Gamma[5/4]*Hypergeometric2F1[5/4,
1/2, 7/4, 1/3] -
2*Gamma[7/4]*(AppellF1[5/4, 1/2, 1/2, 9/4, (1/3)*(2 - Sin[1]), 2
- Sin[1]]*(2 - Sin[1])^(5/4) +
AppellF1[5/4, 1/2, 1/2, 9/4, (1/3)*(2 - Sin[4]), 2 - Sin[4]]*(2
- Sin[4])^(5/4)))))
3=2E3356211372370748 - 2.324008709185599*I
(-(4/5))*AppellF1[5/4, 1/2, 1/2, 9/4, (1/3)*(2 - Sin[x]), 2 -
Sin[x]]*Sec[x]*Sqrt[1 + (1/3)*(-2 + Sin[x])]*(2 - Sin[x])^(5/4)*
Sqrt[-1 + Sin[x]]
(4*I*(AppellF1[5/4, 1/2, 1/2, 9/4, (1/3)*(2 - Sin[1]), 2 - Sin[1]]*(2
- Sin[1])^(5/4) +
AppellF1[5/4, 1/2, 1/2, 9/4, (1/3)*(2 - Sin[4]), 2 - Sin[4]]*(2 -
Sin[4])^(5/4)))/(5*Sqrt[3])
3=2E3356211372370748
3=2E3356211372353624

Interestingly

Drop[Expand[Integrate[(2 - Sin[x])^(1/4), {x, 1, 4}]], 1]
Chop[N[%]]

(8*I*AppellF1[5/4, 1/2, 1/2, 9/4, (1/3)*(2 - Sin[1]), 2 - Sin[1]]*(2 -
Sin[1])^(1/4))/(5*Sqrt[3]) -
(4*I*AppellF1[5/4, 1/2, 1/2, 9/4, (1/3)*(2 - Sin[1]), 2 - Sin[1]]*(2
- Sin[1])^(1/4)*Sin[1])/(5*Sqrt[3]) +
(8*I*AppellF1[5/4, 1/2, 1/2, 9/4, (1/3)*(2 - Sin[4]), 2 - Sin[4]]*(2
- Sin[4])^(1/4))/(5*Sqrt[3]) -
(4*I*AppellF1[5/4, 1/2, 1/2, 9/4, (1/3)*(2 - Sin[4]), 2 - Sin[4]]*(2
- Sin[4])^(1/4)*Sin[4])/(5*Sqrt[3])
3=2E3356211372370743

(i.e. ommiting the whole Hypergeometric term)

Dimitris


=CF/=C7 dimitris =DD=E3=F1=E1=F8=E5:

> x == 2*Pi - ArcCos[-5] || x == 4*Pi - ArcCos[-5] || x == ArcC=


os[-5] ||
> x == 2*Pi + ArcCos[-5]
> {{x -> Pi - I*Log[5 - 2*Sqrt[6]]}, {x -> 3*Pi - I*Log[5 - 2*Sqrt[6]]},
> {x -> Pi + I*Log[5 - 2*Sqrt[6]]},
> {x -> 3*Pi + I*Log[5 - 2*Sqrt[6]]}}
>
> Of course F[4Pi]-F[0]=0 incorrectly.
>
> The reason for the discrepancy in the above result is not because of
> any problem with the fundamental theorem of calculus, of course; it is
> caused by the multivalued nature of the indefinite integral arctan.
>
>
> Show[GraphicsArray[Block[{$DisplayFunction = Identity},
> (ContourPlot[#1[F[x + I*y]], {x, 0, 4*Pi}, {y, -4, 4}, Contours ->
> 50, PlotPoints -> 50, ContourShading -> False,
> FrameTicks -> {Range[0, 4*Pi, Pi], Automatic, None, None},
> Epilog -> {{PointSize[0.03], Red, poi},
> {Blue, Line[{{0, 0}, {4*Pi, 0}}]}}] & ) /@ {Re, Im}]],
> ImageSize -> 500]
>
> So, in this example the discontinuities are indeed from the branch
> cuts that start and end from the simple poles of the integrand which
> is in agreement with V.A. paper!
>
>
> I think I am not aware of something fundamental!
> Can someone point out what I miss?
>
>
> Regards
> Dimitris


"#FFFFFF">
<tr>
<td><table width="644" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="64"><img src="http://www.usa.canon.com/app/emails/eosmarch07/images/top_3_mar07.jpg" width="644"
height="64"></td>
</tr>
<tr>
<td><table width="644" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td height="97" colspan="2"><a href="http://campman1.usa.canon.com/ema/www/r?1000064389.6114.3.kvdilAs5RWz1dJ" target="_blank"><img
src="http://www.usa.canon.com/app/emails/eosmarch07/images/main_img_01.gif" width="644" height="97" border="0"></a></td>
</tr>
<tr>
<td width="394" rowspan="2"><a href="http://campman1.usa.canon.com/ema/www/r?1000064389.6114.3.kvdilAs5RWz1dJ" target="_blank"><img
src="http://www.usa.canon.com/app/emails/eosmarch07/images/main_img_02.jpg" width="394" height="304" border="0"></a></td>
<td width="250" height="112"><a href="http://campman1.usa.canon.com/ema/www/r?1000064389.6114.3.kvdilAs5RWz1dJ" target="_blank"><img
src="http://www.usa.canon.com/app/emails/eosmarch07/images/main_img_03.gif" width="250" height="112" border="0"></a></td>
</tr>
<tr>
<td width="250" height="192"><a href="http://campman1.usa.canon.com/ema/www/r?1000064389.6114.3.kvdilAs5RWz1dJ" target="_blank"><img
src="http://www.usa.canon.com/app/emails/eosmarch07/images/main_img_04.gif" width="250" height="192" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="4"><img src="http://www.usa.canon.com/app/emails/eosmarch07/images/greybar.gif" width="644"
height="4"></td>
</tr>
<tr>
<td><table width="644" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="322" height="242"><a
href="http://campman1.usa.canon.com/ema/www/r?1000064389.6114.5.x$VipZUb8V$WrS" target="_blank"><img
src="http://www.usa.canon.com/app/emails/eosmarch07/images/eos5d_ef24-105.jpg" width="322" height="242" border="0"></a></td>
<td width="322" height="242"><a
href="http://campman1.usa.canon.com/ema/www/r?1000064389.6114.7.AcE1Ouz95w8Xcy" target="_blank"><img
src="http://www.usa.canon.com/app/emails/eosmarch07/images/eos30d_ef28-135.jpg" width="322" height="242" border="0"></a></td>
</tr>
<tr>
<td height="49" colspan="2"><a
href="http://campman1.usa.canon.com/ema/www/r?1000064389.6114.9.VskROexR5HxSA0" target="_blank"><img
src="http://www.usa.canon.com/app/emails/eosmarch07/images/newlenskit.gif" width="644" height="49" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="12"><img src="http://www.usa.canon.com/app/emails/eosmarch07/images/greybar.gif" width="644"
height="12"></td>
</tr>
<tr>
<td><table width="644" border="0" cellspacing="0" cellpadding="0">
<tr>

dh

unread,
Mar 22, 2007, 2:30:44 AM3/22/07
to

Hi Dimitris,

if an anylytic function is multivalued with singularities, people often

try nevertheless to define a continuous single valued function. This is

not possible globally, there are always places where we will have a

misfit. One therefore cuts the plane and defines "branch cuts" where the

new function is not continuous. Away from these cuts the function is

continuous. Note that these cuts are not clear cut. As long as we get a

continuos function, we can choose the cuts as we please. Further, as the

original function is multivalued, we can define even more different

continuous functions.

Now concerning the fundmental theorem, it seems clear that if we cross

the branch cut the theorem can not be applied. It only works if the

antiderivative is continuous in the integration range. In your case:

ArcTan[(1 + x)/(4 - x^2)], the branch cut was chosen so that we have a

discontinuity at x=2. If we had chosen the branch cuts differently, we

may have been able to find a function that is continuous in 0..4. But

this is not easily done! At least not analytically. However, you may

easily do so numerically in the real domain (although the function may

not be non-analytical (no power series)).

Daniel

David W.Cantrell

unread,
Mar 23, 2007, 8:06:28 PM3/23/07
to
"Michael Weyrauch" <michael....@gmx.de> wrote:
> Hello,
>
> another nice example, where the result for the integral given by
> Mathematica just cannot be right.

I understand your point, but it's impossible to have a result here which
is "right" throughout the complex plane.

> The indefinite integral of a continuuos function cannot have a jump.

Again, I understand your point. You're thinking just about integrating
along the real line; the integrand

(x^2 + 2x + 4)/(x^4 - 7x^2 + 2x + 17)

is indeed continuous there. But computer algebra systems sometimes give
antiderivatives which are "right" only piecewise. You're welcome to
consider that unfortunate in this case because we can do better; see below.

> That -- to my opinion -- is mathematical
> nonsens. We all learned that integration "smoothens", i.e. if the
> integrand is somewhat "ugly" the integral is less "ugly". (Never mind my
> English!).
>
> So the result should actually be presented as
>
> F[x_]=ArcTan[(1 + x)/(4 - x^2)]*UnitStep[2 - x] +
> (Pi + ArcTan[(1 + x)/(4 - x^2)])*UnitStep[-2 + x]

No, not if you're wanting an antiderivative valid along the whole real
line. Your F has a jump discontinuity at x = -2. Furthermore, it is
Indeterminate at x = +2, although that singularity is removable.

Back in December, in the thread which led to this one, I gave an
antiderivative which is continuous along the whole real line:

ArcTan[(4x + Sqrt[2(15 + Sqrt[241])])/(2 - Sqrt[2(-15 + Sqrt[241])])] +
ArcTan[(4x - Sqrt[2(15 + Sqrt[241])])/(2 + Sqrt[2(-15 + Sqrt[241])])]

David W. Cantrell

Daniel Lichtblau

unread,
Mar 23, 2007, 8:07:29 PM3/23/07
to
Michael Weyrauch wrote:
> Hello,
>
> another nice example, where the result for the integral given by Mathematica just
> cannot be right. The indefinite integral of a continuuos function cannot have a jump.

This is simply untrue. 1/x is continuous away from the pole. But any
antiderivative (a logarithm) of necessity will have a branch cut from 0
to (complex) infinity. All one might do is control where to put it.
Mathematica by and large makes no effort to do that, but instead opts to
use whatever forms of antiderivatives it finds, with their branch cuts
given by convention, and then to look for crossings on the integration
path. In future versions (not the next one...) there may be some effort
to formulate some antiderivatives more carefully so that branch
crossings are avoided.


> That -- to my opinion -- is mathematical nonsens. We all learned that integration "smoothens",
> i.e. if the integrand is somewhat "ugly" the integral is less "ugly". (Never mind my English!).

This really applies to definite integration, as covered in "functions of
a real variable" courses. Indefinite integration, that is, finding
antiderivatives, is more in the realm of "foa complex variable". (I
realize exceptions are made for e.g. distribution theory.) My point
being that, in the complex plane, antiderivatives that are continuous
almost everywhere may sometimes require branch cuts.


> So the result should actually be presented as
>
> F[x_]=ArcTan[(1 + x)/(4 - x^2)]*UnitStep[2 - x] +

> (Pi + ArcTan[(1 + x)/(4 - x^2)])*UnitStep[-2 + x]


>
> This is a perfectly nice function without jumps and it is the antiderivative of your integrand,
> and the fundamental theorem of calculus works with it...
>
> So, despite my love for Mathematica, here it fools me....
>
> Regards Michael
>

Not really. What you have is a nonanalytic "antiderivative" for which
the FTOC will work on the real line. I do not dispute that this can be
useful, when doing definite integration. Indeed, it might be viewed as a
way of altering an antiderivative so as to avoid branch crossings. But
it is not a valid antiderivative in the sense of complex analysis.


Daniel Lichtblau
Wolfram Research


Daniel Lichtblau

unread,
Mar 23, 2007, 8:09:32 PM3/23/07
to
dimitris wrote:
> And here is one case that evaluating first the indefinite integral and
> then
> apply the Newton-Leibniz formula is preferable than trust Definite
> Integration
> capabillities of Mathematica

Only if you subscribe to the dictum "two wrongs make a right". More below.

> [...]

The antiderivative appears to have two singularities on the integration
path, one at Pi/2 and one just below 4. I would surmise that latter is
some transcendental, and Mathematica fails to find it. So the definite
integral misses a jump and is incorrect.

The blind application of Newton-Leibniz simply misses both, the jumps
happen to cancel, and the result is "correct". But not the method.


Daniel Lichtblau
Wolfram Research

Andrzej Kozlowski

unread,
Mar 23, 2007, 8:10:33 PM3/23/07
to
Here is, I think, a less confusing explanation than the one I sent
earlier (the main point is the same).

I agree that Adamchik's phrasing is very unclear and confusing. It
seems to me that to understand his intention it helps to consider the
situation in the complex plane.

First of all, consider the integrand f[x_]:=(x^2 + 2*x + 4)/(x^4 -
7*x^2 + 2*x + 17). It is a meromorphic function in the complex
plane. If this were an analytic function than it would have an
analytic anti-derivative, but as it is not, it can only have an
analytic anti-derivative in any simply connected region in which it
is analytic. The integrand f has poles at 2 conjugate pairs of
points in the complex plane. If you join these points by vertical
lines and remove the lines from the plane, you will divide the plane
into three open simply connected regions. In each of these regions
the function will have some analytic anti-derivative, and if you knew
it you would be able to use the Newton-Leibniz formula in this
region. So if you consider the anti-derivative given by Mathematica

FullSimplify[ArcTan[(x + 1)/
(4 - x^2)]]


ArcTan[(x + 1)/(4 - x^2)]


You can use the Newton-Leibniz formula in any region in which the
anti-derivative is analytic. At all such points the integrand will be
automatically analytic. In any region where the anti-derivative is
not analytic special care is needed.

If you restrict the integrand to the real interval 0<=x<=4, then,
since it has no singularities there, it has some continuous real anti-
derivative, and if you can find it you can also apply the Newton-
Leibniz formula in the "naive" way, on the real line of course. But
we know that any such anti-derivative can't be given by a restriction
of any complex analytic function in the plane. In other words, any
anti-derivative will have to have singularities somewhere (including
all the points where the integrand is singular).

As far as I can tell, all that Adamchik's statement that "the
discontinuities in the anti-derivative are caused by the
discontinuities in the integrand" means is that one could not
represent the anti-derivative by a complex analytic function. I
don't think the statement is meant to imply any special relationship
between the numbers +/- 2 and the complex poles of f. In fact, (it
seems to me) the appearence of these real singularities in the anti-
derivative is an "accident" and there may well be other anti-
derivatives that do not have them (?). Adamchik's statement seems to
suggest that somehow the complex singularities of the integrand
"cause" the real singularities of the anti-derivative but I don't see
any basis for this. All I think he meant was that "there have to be
some singularities" in the anti-derivative.

Note that in fact the anti-derivative

ArcTan[(x + 1)/(4 - x^2)]

apart from the branch points at x=+/- 2 has also singularities at the
poles of the integrand f, since

FullSimplify[(-x - 1)/(x^2 - 4) /.
Solve[x^4 - 7*x^2 + 2*x + 17 == 0,
x]]

{-I, -I, I, I}

At all these points are of course singularities of ArcTan, as one
would expect them to be. On the other hand,


D[ArcTan[(-x - 1)/(x^2 - 4)], x]


(-((2*(-x - 1)*x)/(x^2 - 4)^2) -
1/(x^2 - 4))/
((-x - 1)^2/(x^2 - 4)^2 + 1)

has removable singularities at +/- 2.

Andrzej Kozlowski

On 22 Mar 2007, at 07:07, dimitris wrote:

>
> Hello Daniel!
>
> Of course I am aware of branch cuts and the stuff!
>
> May be I was not too clear in order someone to understand me!
>
> Read the first 4 pages of the paper of V Adamichik's Definite
> Integration
> in Mathematica v. 3.0. available from here:
>
> http://library.wolfram.com/infocenter/Articles/3157/
>
> I will try to set my question as clear as I can!
>
> The integral that appears in V.A. paper is
>
> f = HoldForm[Integrate[(4 + 2*x + x^2)/(17 + 2*x - 7*x^2 + x^4), {x,
> 0, 4}]]
>
> and the integrand is a smooth integrable function in the whole real
> axis.
>
> Mathematica's answer of (symbolic) definite integration is
>
> ReleaseHold@%

> Pi - ArcTan[1/4] - ArcTan[5/12]
>

> which agrees with the result obtained by numerical integration
>
> {(N[#1, 20] & )[%], ReleaseHold[f /. Integrate[x___] :> NIntegrate[x,
> WorkingPrecision -> 40,
> AccuracyGoal -> 20]]}
> {2.5018228707631675676, 2.50182287076316756755}
>
> Everything is ok up to now! And as I have shown in an old post you can
> using Mathematica to get a continuus
> antiderivative in the integration range but this is not my goal! I am
> very happy by Mathematica's antiderivative which is rather simple
> contrary to my expression.
>
> Mathematica uses (an extended version of) Risch algorithm in order to
> get an antiderivative

> for [(x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17)
>
> Simplify[Integrate[(x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17), x]]


> ArcTan[(1 + x)/(4 - x^2)]
>

> and due to the jump discontinuity of ArcTan at x=2 the correct way in

> order to apply the Newton-Leibniz formula
> is
>


> (% /. x -> 4) - Limit[%, x -> 2, Direction -> -1] + Limit[%, x -> 2,
> Direction -> 1] - (% /. x -> 0)

> Pi - ArcTan[1/4] - ArcTan[5/12]
>

dimitris

unread,
Mar 23, 2007, 8:16:40 PM3/23/07
to
You miss one important thing!

(x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17) (the function in discussion)
is indeed continuous in the whole
real axis.

(We don't talk just for Reimmanian integration in the real axis as
most of calculus
books deal with! It is rather an issue of Complex Analysis.)

But what about the complex plane?

If it was analytic everywhere in the complex plane then it would have
an analytic anti-
derivative everywhere, but here is not the case. The function has four
poles in the complex plane!

Also convince yourself that the antiderivative returned by Mathematica
is indeed right.
(there is of course, in general, a whole family of results which have
the property that their derivative is the
integrand).

In[237]:=
Derivative[-1][(#1^2 + 2*#1 + 4)/(#1^4 - 7*#1^2 + 2*#1 + 17) & ][x]
Simplify[%]
D[%, x]
Simplify[%]

Out[237]=
(1/2)*ArcTan[(-1 - x)/(-4 + x^2)] - (1/2)*ArcTan[(1 + x)/(-4 + x^2)]

Out[238]=


ArcTan[(1 + x)/(4 - x^2)]

Out[239]=
((2*x*(1 + x))/(4 - x^2)^2 + 1/(4 - x^2))/(1 + (1 + x)^2/(4 - x^2)^2)

Out[240]=


(4 + 2*x + x^2)/(17 + 2*x - 7*x^2 + x^4)

In another symbolic system (again the policy of MathGroup does not
allow to mention its name)
I get indeed a continuous antiderivative in the whole real axis

int((x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17),x);
arctan(5/3-x-1/3*x^2+1/3*x^3)+arctan(x-1)
plot(%,x=-10..10);

but this does not say anything for the integration algorithm of
Mathematica!

As the function is not analytic it will only have an analytic anti-


derivative in any simply connected region in which it is analytic.

So any candidate for an antidrivative of this function, will have
to
have singularities somewhere in the region.

Before proceeding a check is done

In[246]:=
D[other, x]
Simplify[%]

Out[246]=
1/(1 + (1 - x)^2) + (-1 - (2*x)/3 + x^2)/(1 + (5/3 - x - x^2/3 +
x^3/3)^2)

Out[247]=


(4 + 2*x + x^2)/(17 + 2*x - 7*x^2 + x^4)

Let compare now the two candidate antiderivatives

In[250]:=
math = ArcTan[(1 + x)/(4 - x^2)]; (*mathematica's antiderivative*)
other = ArcTan[5/3 - x - (1/3)*x^2 + (1/3)*x^3] + ArcTan[x - 1];
(*other CAS antiderivative*)

See the following graphs

In[254]:=


Show[GraphicsArray[Block[{$DisplayFunction = Identity},

(ContourPlot[Evaluate[#1[math /. x -> x + I*y]], {x, -4, 4}, {y, -3,
3}, ContourShading -> False, PlotPoints -> 50, Contours -> 50] & ) /@
{Re, Im}], Frame -> True], ImageSize -> 600, PlotLabel -> "math
antiderivative"];

Show[GraphicsArray[Block[{$DisplayFunction = Identity},

(ContourPlot[Evaluate[#1[other /. x -> x + I*y]], {x, -4, 4}, {y, -3,
3}, ContourShading -> False, PlotPoints -> 50, Contours -> 50] & ) /@
{Re, Im}], Frame -> True],
ImageSize -> 600, PlotLabel -> "other CAS antiderivative"];

Show[GraphicsArray[Block[{$DisplayFunction = Identity},

(Plot3D[Evaluate[#1[math /. x -> x + I*y]], {x, -4, 4}, {y, -3, 3},
PlotPoints -> 50] & ) /@ {Re, Im}], Frame -> True], ImageSize -> 800,
PlotLabel -> "math antiderivative"];

Show[GraphicsArray[Block[{$DisplayFunction = Identity},

(Plot3D[Evaluate[#1[other /. x -> x + I*y]], {x, -4, 4}, {y, -3, 3},
PlotPoints -> 50] & ) /@ {Re, Im}], Frame -> True], ImageSize -> 800,
PlotLabel -> "other CAS antiderivative"];

I think you are convinced now that both antiderivatives have
discontinuities in
the complex plane! It's just happens the returned antiderivative from
the other
CAS to be continuous in the real axis; it's a matter of choice of the
region of
analyticity!

Note also that

In[260]:=
math - other
Plot[Chop[%], {x, -3, 3}, Axes -> False, Frame -> True]

I=2Ee. in the real axis the two antiderivatives differ by a piecewise
(complex as we saw in the next plot) constant function and inside
(-2,2) are equally!

In[264]:=


Show[GraphicsArray[Block[{$DisplayFunction = Identity},

(Plot3D[Chop[Evaluate[#1[math - other /. x -> x + I*y]]], {x, -4, 4},
{y, -3, 3}, PlotPoints -> 50] & ) /@ {Re, Im}], Frame -> True],
ImageSize -> 800];

Obviously

In[271]:=
D[math - other, x]
Simplify[%]

Out[271]=
-(1/(1 + (1 - x)^2)) + ((2*x*(1 + x))/(4 - x^2)^2 + 1/(4 - x^2))/(1 +
(1 + x)^2/(4 - x^2)^2) -
(-1 - (2*x)/3 + x^2)/(1 + (5/3 - x - x^2/3 + x^3/3)^2)
Out[272]=
0

So everything is normal regarding the application of the Newton
Leibniz formula
as the following demonstrates:

In[279]:=
FullSimplify[(math /. x -> 4) - Limit[math, x -> 2, Direction -> -1] +
Limit[math, x -> 2, Direction -> 1] -
math /. x -> 0]
N[%]
FullSimplify[(other /. x -> 4) - (other /. x -> 0)]
N[%]

Out[279]=
Pi - (1/2)*ArcTan[2752/825]
Out[280]=
2=2E5018228707631676
Out[281]=
(1/4)*(3*Pi + 2*ArcTan[825/2752])
Out[282]=
2=2E5018228707631676

Then the question is:
Can we use Mathematica to get an antiderivative continuous in the real
axis?
Certainly we can for this example.

But usually the process of builting an antiderivative continuous in a
given integral
is a very tough procedure. But, note that we can't get rid of the
brach cuts!

(At last I think I understand Adamchik's article; Thanks a lot Daniel
Huber and
Andrzej Kozlowski!)

So for the our integrand (copy/paste the following as a WHOLE cell)

In[1471]:=
Print["the integrand"]
f[x_] = (4 + 2*x + x^2)/(17 + 2*x - 7*x^2 + x^4)
Print["\[Cross]partial fraction decomposition procedure\[Cross]"]
Print["the denominator of f[x] as a product of terms"]
Times @@ Apply[#1[[1]] - #1[[2]] & , Solve[Denominator[f[x]] == 0, x],
1]
Print["f[x] as a sum of fractions"]
Map[FullSimplify, Apart[(4 + 2*x + x^2)/%%], 1]
Print["Integrate each term of above sum"]
F = (Integrate[#1, x] & ) /@ %%
Print["plot of the antiderivative"]
Plot[%%, {x, -10, 10}, Axes -> False, Frame -> True];
Print["verification"]
FullSimplify[D[F, x] == f[x]]
Print["the definite integral in the interval [0,4]"]
(F /. x -> 4) - (F /. x -> 0)
Print["numerical value"]
%%//N//Chop

Do you prefer the extend antiderivative over the compact one obtained
directly
by Mathematica only because is real in the real axis?
As regards myself, no!

Of course the question of simplifications arises now but this is not
then subject of the
current thread!

Regards
Dimitris

/=C7 Michael Weyrauch =DD=E3=F1=E1=F8=E5:
> Hello,
>
> another nice example, where the result for the integral given by Mathem=
atica just
> cannot be right. The indefinite integral of a continuuos function cannot =
have a jump.
> That -- to my opinion -- is mathematical nonsens. We all learned that int=
egration "smoothens",
> i.e. if the integrand is somewhat "ugly" the integral is less "ugly". (Ne=


ver mind my English!).
>
> So the result should actually be presented as
>
> F[x_]=ArcTan[(1 + x)/(4 - x^2)]*UnitStep[2 - x] +
> (Pi + ArcTan[(1 + x)/(4 - x^2)])*UnitStep[-2 + x]
>

> This is a perfectly nice function without jumps and it is the antideriva=


tive of your integrand,
> and the fundamental theorem of calculus works with it...
>
> So, despite my love for Mathematica, here it fools me....
>
> Regards Michael
>
>
>
>

> "dimitris" <dimm...@yahoo.com> schrieb im Newsbeitrag news:etqo3f$10i$1=

> > x == 2*Pi - ArcCos[-5] || x == 4*Pi - ArcCos[-5] || x == Ar=

dh

unread,
Mar 23, 2007, 8:19:47 PM3/23/07
to

Hello Dimitris,

Yes, you are right, Mathematica chooses an antiderivative function that

has branch cuts at approx. +/-2. However, this is not the only possible

antiderivative, there are others with different branch cuts. But it is

not too easy to find them.

Daniel

m...@inbox.ru

unread,
Mar 23, 2007, 8:25:55 PM3/23/07
to

The branch cuts in this case are not straight line segments. Here's a
way to visualize them. Take the antiderivative:

In[1]:= adz = Integrate[(z^2 + 2*z + 4)/(z^4 - 7*z^2 + 2*z + 17), z]

Out[1]= (1/2)*ArcTan[(-1 - z)/(-4 + z^2)] - (1/2)*ArcTan[(1 + z)/(-4 +
z^2)]

In[2]:= adz = ComplexExpand[adz, z, TargetFunctions -> {Re, Im}] //
Simplify

The discontinuities might occur because of ArcTan[x, y] with x
negative and y zero:

In[3]:= dc = Union@ Cases[adz, ArcTan[x_, y_] :> {x, y}, -1] /.
{Re[z] -> u, Im[z] -> v}

In[4]:= <<graphics`
DisplayTogether[
{InequalityPlot[#[[1]] < 0, {u, -3, 3}, {v, -3, 3}],
ImplicitPlot[#[[2]] == 0, {u, -3, 3}, {v, -3, 3}]}& /@
dc]

The disks show where x < 0 and the curves show where y == 0. So the
branch cuts are the pieces of the curves that lie inside the circles.
The picture doesn't show which curve belongs to which disks, but it
gives the general idea.

Maxim Rytin
m...@inbox.ru


Peter Pein

unread,
Mar 24, 2007, 6:31:49 AM3/24/07
to
dh schrieb:

> Hello Dimitris,
>
> Yes, you are right, Mathematica chooses an antiderivative function that
>
> has branch cuts at approx. +/-2. However, this is not the only possible
>
> antiderivative, there are others with different branch cuts. But it is
>
> not too easy to find them.
>
> Daniel
>

But it is quite easy to do this in Mathematica:

In[1]:= << "DiscreteMath`"
In[2]:= f[x_] = (4 + 2*x + x^2) / (17 + 2*x - 7*x^2 + x^4);
In[3]:= F[x_] = Simplify[Assuming[k >= 0 && k \[Element] Integers,
PowerSum[Simplify[ToRadicals[(x/(k + 1))*SeriesTerm[f[x], {x, 0, k}]]],
{x, k}]]]
Out[3]=
(-(1/2))*I*(Log[34 + (1 + 4*I)*x - Sqrt[257 - 60*I]*x] +
Log[34 + ((1 + 4*I) + Sqrt[257 - 60*I])*x] -
Log[34 - ((-1 + 4*I) + Sqrt[257 + 60*I])*x] -
Log[34 + ((1 - 4*I) + Sqrt[257 + 60*I])*x])

In[4]:= FullSimplify[F[4] - F[0]]
Out[4]= Pi - (1/2)*ArcTan[2752/825]
In[5]:= N[%]
Out[5]= 2.5018228707631676
In[6]:= Plot[F[x], {x, -4, 4}]
...

This will propably work for "simple enough" (whatever that means) rational
functions.


Peter

dimitris

unread,
Mar 25, 2007, 2:32:46 AM3/25/07
to
Thanks to all that contribute to this thread.

Namely Daniel Huber, Andrzej Kozlowski (I got the point about Adamchik
article!)
Daniel Lichtblau, David Cantrell, Michael Weyrauch and of course Maxim
Rytin for
offering a clear visualization.

Last but not least. I would like to thank (and congratulate!) Peter
Pein (...P^2!) for his
amazing method to construct a continuous antiderivative.

Best Regards to all!

Dimitris

=CF/=C7 dimitris =DD=E3=F1=E1=F8=E5:

> x == 2*Pi - ArcCos[-5] || x == 4*Pi - ArcCos[-5] || x == ArcC=

Michael Weyrauch

unread,
Mar 26, 2007, 3:14:56 AM3/26/07
to
Hello,

thanks, Dimitris, for bringing up this issue. (By the way, as I just realized, Michael Trott
in his book on symbolics has quite some interesting things to say related to this issue.)

My remark in this thread clearly was written in the spirit of "functions of one real
variable". As I see my statements are clearly incorrect in the sense of "functions of a complex
variable".

However, in many practical applications people want to have an integral in the
former sense, and it is very disconcerting to fall down a discontinuity step along
an integral of a continous integrand on the real line due to a singularity of the
integrand somewhere in the complex plane. Therefore, I guess, the designers of "the other
CAS", which Dimitris uses for comparison, obviously opted to return an integral, which is continuous along
the real axis (if such an integral is available in the set of possible solutions).

This is not just a matter of aestetics or simplicity as Dimitris remark in this thread may suggest

>Do you prefer the extend antiderivative over the compact one obtained
>directly
>by Mathematica only because is real in the real axis?
>As regards myself, no!

In applications we have to use that solution which makes practical sense, and in many
applications it's the integral which is continouus (and differentiable) for a continouus integrand
on the real axis. Of course, it's my task as a physicist or engineer to see if a mathematical
solution serves my purposes or not, however, in such rather intriguing cases, it would be
desirable that the designers of Mathematica would help me by providing an Option
to Integrate, in which I could ask for an integral which is continuous on the real axis if such an integral
exists for a particular integrand.
(As I understand the remark of Daniel Lichtblau in some future version of Mathematica
they may provide such an Option).

Thanks again

Michael Weyrauch

Andrzej Kozlowski

unread,
Mar 27, 2007, 5:10:34 AM3/27/07
to


I am not convinced that there is a genuine need for this. This may be
due my lack of knowledge of applied mathematics but I cannot see any
advantage in having a complicated (non-analytic) anti-derivative,
even a continuous one, on the real axis over simply doing this:


g = First[g /. NDSolve[{Derivative[1][g][x] == (4 + 2*x + x^2)/(17 +
2*x - 7*x^2 + x^4), g[0] == 0}, g,
{x, 0, 4}]];

You get a smooth function with which you can perform any computations
you like with excellent accuracy, as you can see from:


Plot[{Derivative[1][g][x], (4 + 2*x + x^2)/(17 + 2*x - 7*x^2 + x^4)},
{x, 0, 4},
PlotStyle -> {Green, Red}]

What is there that is useful in applications and that you can do with
a symbolic anti-derivative but you can't with this interpolating
function?
(The situation is quite different in the complex case, where having a
function that is actually complex analytic even in some part of the
complex plane can be a huge advantage over just having an
interpolating function).

Andrzej Kozlowski

dimitris

unread,
Mar 27, 2007, 5:14:38 AM3/27/07
to
>(By the way, as I just realized, Michael Trott
> in his book on symbolics has quite some interesting things to say related=
to this issue.)

There are a great many books about Mathematica.

Bu definetely if you want a book that combines Mathematica
with advanced mathematics for a various scientific fields (even form
current research) this book is Trott's Guidebooks. The whole series
deserves the money.

> However, in many practical applications people want to have an integral i=
n the
> former sense, and it is very disconcerting to fall down a discontinuity s=
tep along
> an integral of a continous integrand on the real line due to a singularit=
y of the
> integrand somewhere in the complex plane. Therefore, I guess, the design=
ers of "the other
> CAS", which Dimitris uses for comparison, obviously opted to return an in=


tegral, which is continuous along

> the real axis (if such an integral is available in the set of possible so=
lutions).

It's just happen in this case the antiderivative returned by the other
CAS to be continuous
in the real axis. For other integrals usually discontinuous
antiderivatives are returned.
For example

(*other CAS*)
int(1/(5+cos(x)),x);
1/6*6^(1/2)*arctan(1/3*tan(1/2*x)*6^(1/2))

(*mathematica*)
Integrate[1/(5 + Cos[x]), x]


ArcTan[Sqrt[2/3]*Tan[x/2]]/Sqrt[6]

both have jump discontinuity at x=+/- n*Pi, n=odd.

See this thread for a clever method by Peter Pein in order
to get a continuous antiderivative with Mathematica.

But in case of recognizing the jump discontinuity and its position, it
is
very easy to obtain a continous antiderivative adding the piecewise
constant (see the relevant example from Trott's book!)

Also based on my experience Mathematica is quantum steps
in front of other CAS (no I don't take any money from WRI!)
regarding integration capabilities.

For an example let

f = HoldForm[Integrate[Cos[Log[z]]/(1 + z^2)^Pi, {z, 0, Infinity}]]

The indefinite integral first

ReleaseHold[f /. Integrate[h_, {x_, __}] :> Integrate[h, x]]
FullSimplify[D[%, z] == Cos[Log[z]]/(1 + z^2)^Pi]

(1/4 + I/4)*z^(1 - I)*Hypergeometric2F1[1/2 - I/2, Pi, 3/2 - I/2, -
z^2] +
(1/4 - I/4)*z^(1 + I)*Hypergeometric2F1[1/2 + I/2, Pi, 3/2 + I/2, -
z^2]
True

The definite integral along with check...

Timing[g=ReleaseHold[f]]
{145.422*Second, (Pi*(-((Gamma[1/2 - I/2]*Sech[(1/2)*(1 - 2*I*Pi)*Pi])/
Gamma[(3/2 - I/2) - Pi]) -
(Gamma[1/2 + I/2]*Sech[(1/2)*(1 + 2*I*Pi)*Pi])/Gamma[(3/2 + I/2)
- Pi]))/(4*Gamma[Pi])}

{Chop[N[F, 21]], ReleaseHold[f /. Integrate[x___] :> NIntegrate[x,
WorkingPrecision -> 50, PrecisionGoal -> 20]]}
{0.142291882821508343786,0.142291882821508343786}

In my point of view this is a very tough integral (appeared in another
forum).
And getting an analytic result clearly demonstrates Mathematica's
integration
capabilities!

Let compare it with the other CAS I used in order to compare sometimes
its results with Mathematica
and vice versa...

The definite integral first

int(cos(ln(z))/(1+z^2)^Pi, z= 0..infinity);
int(cos(ln(z))/((1+z^2)^Pi),z = 0 .. infinity)

and now the indefinite

int(cos(ln(z))/(1+z^2)^Pi, z);
int(cos(ln(z))/((1+z^2)^Pi),z)

No results!

A numerical integration is possibly of course

evalf(Int(cos(ln(z))/(1+z^2)^Pi, z= 0..infinity););
0=2E1422918828


Best Regards
Dimitris


=CF/=C7 Michael Weyrauch =DD=E3=F1=E1=F8=E5:
> Hello,
>
> thanks, Dimitris, for bringing up this issue. (By the way, as I just r=
ealized, Michael Trott
> in his book on symbolics has quite some interesting things to say related=
to this issue.)
>
> My remark in this thread clearly was written in the spirit of "functions =
of one real
> variable". As I see my statements are clearly incorrect in the sense of =


"functions of a complex
> variable".
>

> However, in many practical applications people want to have an integral i=
n the
> former sense, and it is very disconcerting to fall down a discontinuity s=
tep along
> an integral of a continous integrand on the real line due to a singularit=
y of the
> integrand somewhere in the complex plane. Therefore, I guess, the design=
ers of "the other
> CAS", which Dimitris uses for comparison, obviously opted to return an in=


tegral, which is continuous along

> the real axis (if such an integral is available in the set of possible so=
lutions).
>
> This is not just a matter of aestetics or simplicity as Dimitris remark i=


n this thread may suggest
>
> >Do you prefer the extend antiderivative over the compact one obtained
> >directly
> >by Mathematica only because is real in the real axis?
> >As regards myself, no!
>

> In applications we have to use that solution which makes practical sense,=
and in many
> applications it's the integral which is continouus (and differentiable) f=
or a continouus integrand
> on the real axis. Of course, it's my task as a physicist or engineer to s=
ee if a mathematical
> solution serves my purposes or not, however, in such rather intriguing ca=
ses, it would be
> desirable that the designers of Mathematica would help me by providing a=
n Option
> to Integrate, in which I could ask for an integral which is continuous on=


the real axis if such an integral
> exists for a particular integrand.

> (As I understand the remark of Daniel Lichtblau in some future version of=

David W.Cantrell

unread,
Mar 28, 2007, 2:45:52 AM3/28/07
to
"dimitris" <dimm...@yahoo.com> wrote:
[snip]

> It's just happen in this case the antiderivative returned by the other
> CAS to be continuous in the real axis. For other integrals usually
> discontinuous antiderivatives are returned. For example
>
> (*other CAS*)
> int(1/(5+cos(x)),x);
> 1/6*6^(1/2)*arctan(1/3*tan(1/2*x)*6^(1/2))
>
> (*mathematica*)
> Integrate[1/(5 + Cos[x]), x]
> ArcTan[Sqrt[2/3]*Tan[x/2]]/Sqrt[6]
>
> both have jump discontinuity at x=+/- n*Pi, n=odd.
>
> See this thread for a clever method by Peter Pein in order
> to get a continuous antiderivative with Mathematica.

You seem to be implying that Peter's method can be used to produce an
antiderivative, continuous on R, for 1/(5 + Cos[x]). I don't see how. Could
you please show us?

> But in case of recognizing the jump discontinuity and its position, it
> is very easy to obtain a continous antiderivative adding the piecewise
> constant (see the relevant example from Trott's book!)

Unfortunately, I don't have Trott's book. Since it's very easy to obtain,
could you also please show us the continuous antiderivative for
1/(5 + Cos[x]) obtained by Trott's method?

David W. Cantrell

Michael Weyrauch

unread,
Mar 28, 2007, 2:58:59 AM3/28/07
to
Hello,

well, in case that nothing else is available, I am happy with a numerical solution of a problem.
And that's what NDSolve produces. After all an interpolating function is only a numerical approximation
to the solution looked for -- admittedly in a form easily worked with.

However, generally, even if it looks complicated
an analytical solution has its specific virtues. Just assume that one of the constants in the integral
would actually be a parameter, say a, than I could easily study the parameter dependence of the integral,
which may produce further insight, e.g. that a certain term may or may not be neglected in the parameter range
of interest. (That's the way physicists often make progress...)

(By the way I got a few private messages in response to my post in this newsgroup which strongly supported
the idea that Mathematica should support an option in order to ask for the solution which is
continouus on the real line.)

So, I conclude, (also from reading some of the papers Dimitris suggested) that there is a genuine point to have
an explicit (non-numeric) solution of the integral which is continuous and differentiable on the real line if it exists,
irrespective how complicated it may look.

Nevertheless, your suggestion to use NDSolve spurred my interest, and I tried to use DSolve in order to determine
the integral. And here is what I got,

(*in*)
sol = DSolve[Derivative[1][f][x] == (x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17),

f, x]

(*out*)

{{f -> Function[{x}, (1/2)*ArcTan[(-1 - x)/(-4 + x^2)] -

(1/2)*ArcTan[(1 + x)/(-4 + x^2)] + C[1]]}}

It's exactly our good old friend, which is neither continuous nor differentiable at x=2.

But Mathematica even provides an integration constant so as to make me believe that
this is the solution up to a constant to be determined by an initial condition.
On the left hand side of my equation there just is
f', and what I exspected is a differentiable solution. Or can I also here excuse myself with
singularities in the complex plane?? I definitely thought that DSolve solves differential
equations of one or more REAL variables. ??

In contrast, NDSolve exactly does this as Andrzej Kozlowski has shown in his post.
So, at least, I learn that DSolve and NDSolve do different things (sometimes) apart from
one being analytical and the other numerical.
Is that really intended and mathematically sound?

I would be grateful for further enlightening.

Cheers Michael Weyrauch

dimitris

unread,
Mar 29, 2007, 3:35:03 AM3/29/07
to
Hi.

I apologise for the delay.

I will reply to your questions in this post; but I want the current post
to serve as a sum up of this beautiful thread. So I apologise also for
its considerable length and not anwering at once to your queries.

First things first.

(*change some default settings*)
g == Options[Plot];
h == Options[ContourPlot];
k == Options[Plot3D];
$TextStyle == {FontFamily -> "Times", FontSize -> 12};
SetOptions[Plot, Axes -> False, Frame -> {True, True, False, False},
FrameTicks -> {Range[-4*Pi, 4*Pi, Pi], Automatic}];
SetOptions[ContourPlot, ContourShading -> False, PlotPoints -> 50,
Contours -> 50,
FrameTicks -> {Range[-2*Pi, 2*Pi, Pi], Automatic, None, None}];
SetOptions[Plot3D, PlotPoints -> 50, Ticks -> {Range[-2*Pi, 2*Pi, Pi],
Automatic, Automatic}];

Let

f[x_] :== 1/(2 + Cos[x])

Its plot

Plot[f[x], {x, -4*Pi, 4*Pi}, PlotStyle -> Blue];

The indefinite integral by Mathematica

F[x_] == Integrate[f[x], x]
(2*ArcTan[Tan[x/2]/Sqrt[3]])/Sqrt[3]

Check

Simplify[D[F[x], x] ==== f[x]]
True

Its plot

Show[Block[{$DisplayFunction == Identity}, (Plot[F[x], {x, #1[[1]],
#1[[2]]}, PlotStyle -> Red] & ) /@
Partition[Range[-4*Pi, 4*Pi, Pi], 2, 1]]];

Contour plots and 3D plots.

Show[GraphicsArray[Block[{$DisplayFunction == Identity},
(ContourPlot[#1[f[x + I*y]], {x, -2*Pi, 2*Pi}, {y, -3, 3}] & ) /@ {Re,
Im}]], ImageSize -> 600];

Show[GraphicsArray[Block[{$DisplayFunction == Identity},
(ContourPlot[#1[F[x + I*y]], {x, -2*Pi, 2*Pi}, {y, -3, 3}] & ) /@
{Re, Im}]], ImageSize -> 600];

Show[GraphicsArray[Block[{$DisplayFunction == Identity}, (Plot3D[#1[f[x
+ I*y]], {x, -2*Pi, 2*Pi}, {y, -3, 3}] & ) /@ {Re, Im}]], ImageSize ->
600];

Show[GraphicsArray[Block[{$DisplayFunction == Identity}, (Plot3D[#1[F[x
+ I*y]], {x, -2*Pi, 2*Pi}, {y, -3, 3}] & ) /@ {Re, Im}]], ImageSize ->
600];


The function f has 4 poles in the complex domain withing the range
[-4Pi,4Pi]. Indeed

Reduce[Denominator[f[x]] ==== 0 && -4*Pi < Re[x] < 4*Pi, x]
{ToRules[%]}
% /. (x_ -> a_) :> x -> ComplexExpand[a]
Show[Graphics[{PointSize[0.02], (Point[{Re[#1], Im[#1]}] & ) /@ (x /.
%)}], Axes -> True,
Ticks -> {Range[-4*Pi, 4*Pi, Pi], Automatic}, AxesLabel -> {"Re",
"Im"}];

x ==== -2*Pi - ArcCos[-2] || x ==== 2*Pi - ArcCos[-2] || x ==== 4*Pi -
ArcCos[-2] || x ==== -ArcCos[-2] || x ==== ArcCos[-2] ||
x ==== -4*Pi + ArcCos[-2] || x ==== -2*Pi + ArcCos[-2] || x ==== 2*Pi +
ArcCos[-2]
{{x -> -2*Pi - ArcCos[-2]}, {x -> 2*Pi - ArcCos[-2]}, {x -> 4*Pi -
ArcCos[-2]}, {x -> -ArcCos[-2]}, {x -> ArcCos[-2]},
{x -> -4*Pi + ArcCos[-2]}, {x -> -2*Pi + ArcCos[-2]}, {x -> 2*Pi +
ArcCos[-2]}}
{{x -> -3*Pi - I*Log[2 - Sqrt[3]]}, {x -> Pi - I*Log[2 - Sqrt[3]]}, {x
-> 3*Pi - I*Log[2 - Sqrt[3]]},
{x -> -Pi - I*Log[2 - Sqrt[3]]}, {x -> Pi + I*Log[2 - Sqrt[3]]}, {x -
> -3*Pi + I*Log[2 - Sqrt[3]]},
{x -> -Pi + I*Log[2 - Sqrt[3]]}, {x -> 3*Pi + I*Log[2 - Sqrt[3]]}}
(*plot to be displayed*)

So the integrand has four singular poles that become branch points for
the antiderivative.
Connected in pairs these points make two branch cuts. And the real
axis crosses them.

Table[(Limit[F[x], x -> n*Pi, Direction -> #1] & ) /@ {-1, 1}, {n, -4,
4}]
{{0, 0}, {-(Pi/Sqrt[3]), Pi/Sqrt[3]}, {0, 0}, {-(Pi/Sqrt[3]), Pi/
Sqrt[3]}, {0, 0}, {-(Pi/Sqrt[3]), Pi/Sqrt[3]}, {0, 0},
{-(Pi/Sqrt[3]), Pi/Sqrt[3]}, {0, 0}}

Consider the definite integral in the range [-4Pi,4Pi].

Integrate[f[x], {x, -4*Pi, 4*Pi}]
{N[%], NIntegrate[f[x], {x, -4*Pi, 4*Pi}]}

(8*Pi)/Sqrt[3]
{14.510394913873741, 14.510394913883049}

Obviously

(Integrate[f[x], {x, #1[[1]], #1[[2]]}] & ) /@ Partition[Range[-4*Pi,
4*Pi, Pi], 2, 1]
Tr[%]

{Pi/Sqrt[3], Pi/Sqrt[3], Pi/Sqrt[3], Pi/Sqrt[3], Pi/Sqrt[3], Pi/
Sqrt[3], Pi/Sqrt[3], Pi/Sqrt[3]}
(8*Pi)/Sqrt[3]

Let use a substitution in order to get an indefinite integral

f[x]*dx
% /. Cos[x] -> Cos[x/2]^2 - Sin[x/2]^2
Simplify[% /. x -> 2*ArcTan[z] /. dx -> 2*D[ArcTan[z], z]]
Integrate[%, z]
hand == % /. z -> Tan[x/2]
Simplify[D[%, x]]
Show[Block[{$DisplayFunction == Identity}, (Plot[%%, {x, #1[[1]],
#1[[2]]}, PlotStyle -> Thickness[0.008]] & ) /@
Partition[Range[-2*Pi, 2*Pi, Pi], 2, 1]]];
hand ==== F[x]

dx/(2 + Cos[x])
dx/(2 + Cos[x/2]^2 - Sin[x/2]^2)
2/(3 + z^2)
(2*ArcTan[z/Sqrt[3]])/Sqrt[3]
(2*ArcTan[Tan[x/2]/Sqrt[3]])/Sqrt[3]
1/(2 + Cos[x])
(*plot to be displayed*)
True

I.e. we get in this case (ussually this does not happen!) the result
of Mathematica.
BTW, the other CAS I use got also a similar antiferivative with jump
discontinuities.

>From an old book about Mathematica (Mathematica for Scientists and
Enginners by R. Gass we got (but without further explanation...)

FF[x_] == (-2*3^(1/2)*ArcTan[Sin[x]/(Cos[x] + 1)])/3 +
(2*3^(1/2)*ArcTan[(3^(1/2)*Sin[x])/(3*(Cos[x] + 1))])/3 +
(3^(1/2)*x)/3
D[FF[x], x]//Simplify

x/Sqrt[3] - (2*ArcTan[Sin[x]/(1 + Cos[x])])/Sqrt[3] + (2*ArcTan[Sin[x]/
(Sqrt[3]*(1 + Cos[x]))])/Sqrt[3]
1/(2 + Cos[x])

as a continuous antiderivative in the real axis.

I will be very glad if you could show me how exactly the author get
previous antiderivative
or what method in general would you follow in order to get a
continuous antiderivative in the
real axis.

Plot[{FF[x], F[x]}, {x, -4*Pi, 4*Pi}, PlotStyle -> {Red, Blue}]
Show[GraphicsArray[Block[{$DisplayFunction == Identity},
(ContourPlot[#1[FF[x + I*y]], {x, -2*Pi, 2*Pi}, {y, -4, 4}] & ) /
@ {Re, Im}]],
ImageSize -> 600];
Show[GraphicsArray[Block[{$DisplayFunction == Identity},
(Plot3D[#1[FF[x + I*y]], {x, -2*Pi, 2*Pi}, {y, -4, 4}] & ) /@
{Re, Im}]], ImageSize -> 600];

The two functions differ a piecewise constant function

Plot[F[x] - FF[x], {x, -2*Pi, 2*Pi}, PlotRange -> All];
D[FF[x] - F[x], x]
Simplify[%]

(*plot to be displayed*)
1/Sqrt[3] - (2*(Cos[x]/(1 + Cos[x]) + Sin[x]^2/(1 + Cos[x])^2))/
(Sqrt[3]*(1 + Sin[x]^2/(1 + Cos[x])^2)) +
(2*(Cos[x]/(Sqrt[3]*(1 + Cos[x])) + Sin[x]^2/(Sqrt[3]*(1 +
Cos[x])^2)))/(Sqrt[3]*(1 + Sin[x]^2/(3*(1 + Cos[x])^2))) -
Sec[x/2]^2/(3*(1 + (1/3)*Tan[x/2]^2))
0

So the correct aplication of the Newton Leibniz formula is
respectively

FF[4*Pi] - FF[-4*Pi]
(F[4*Pi] - Limit[F[x], x -> 3*Pi, Direction -> -1]) + (Limit[F[x], x -
> 3*Pi, Direction -> 1] -
Limit[F[x], x -> Pi, Direction -> -1]) + (Limit[F[x], x -> Pi,
Direction -> 1] - Limit[F[x], x -> -Pi, Direction -> -1]) +
(Limit[F[x], x -> -Pi, Direction -> 1] - Limit[F[x], x -> 3*Pi,


Direction -> -1]) +

(Limit[F[x], x -> -3*Pi, Direction -> 1] - F[-4*Pi])

(8*Pi)/Sqrt[3]
(8*Pi)/Sqrt[3]

It is time to answer your first second question

> Unfortunately, I don't have Trott's book. Since it's very easy to obtain,
> could you also please show us the continuous antiderivative for
> 1/(5 + Cos[x]) obtained by Trott's method?

As you see I chose another example (similar to Trott's) because I want
to
show also the continuous antiderivative by Gass' book.

I don't know what you have understood but stating that

> > But in case of recognizing the jump discontinuity and its position, it
> > is very easy to obtain a continous antiderivative adding the piecewise
> > constant (see the relevant example from Trott's book!)

I really mean something like

Fc[x_] :== Piecewise[{{F[x], Inequality[-4*Pi, LessEqual, x, Less,
-3*Pi]}, {Pi/Sqrt[3], x ==== -3*Pi},
{F[x] + 2*(Pi/Sqrt[3]), -3*Pi < x < -Pi}, {4*(Pi/Sqrt[3]), x ==== -
Pi}, {F[x] + 4*(Pi/Sqrt[3]), -Pi < x < Pi},
{6*(Pi/Sqrt[3]), x ==== Pi}, {F[x] + 6*(Pi/Sqrt[3]), Pi < x < 3*Pi},
{8*(Pi/Sqrt[3]), x ==== 3*Pi},
{F[x] + 8*(Pi/Sqrt[3]), Inequality[3*Pi, Less, x, LessEqual,
4*Pi]}}]

I hope you are not dissapointed!

Plot[Fc[x], {x, -4*Pi, 4*Pi}]

Plot[{FF[x], F[x], Fc[x]}, {x, -4*Pi, 4*Pi}, PlotStyle -> {Red, Blue,
Green}];

Of course

Fc[4*Pi] - Fc[-4*Pi]
(8*Pi)/Sqrt[3]

But I am quite sure even if you are not dissapointed you will be right
now!

> You seem to be implying that Peter's method can be used to produce an

> antiderivative, continuous on R, for 1/(5 + Cos[x]). I don't see how. Cou=
ld
> you please show us?

Due to my enthousiasm of the moment forgot to add in rational
functions below

> > See this thread for a clever method by Peter Pein in order
> > to get a continuous antiderivative with Mathematica.

Hot weather!
Also two or three days ago I was writting, I heard the news that I
will be father, so don't misjudge me!

Kind Regards
Dimitris

PS

I would almost forget it!

$TextStyle == {};

(SetOptions[Plot, #1] & ) /@ g;

(SetOptions[ContourPlot, #1] & ) /@ h;

(SetOptions[Plot3D, #1] & ) /@ k;

Clear["Global`*"]

=CF/=C7 David W.Cantrell =DD=E3=F1=E1=F8=E5:


> "dimitris" <dimm...@yahoo.com> wrote:
> [snip]
> > It's just happen in this case the antiderivative returned by the other
> > CAS to be continuous in the real axis. For other integrals usually
> > discontinuous antiderivatives are returned. For example
> >
> > (*other CAS*)
> > int(1/(5+cos(x)),x);
> > 1/6*6^(1/2)*arctan(1/3*tan(1/2*x)*6^(1/2))
> >
> > (*mathematica*)
> > Integrate[1/(5 + Cos[x]), x]
> > ArcTan[Sqrt[2/3]*Tan[x/2]]/Sqrt[6]
> >

> > both have jump discontinuity at x==+/- n*Pi, n==odd.


> >
> > See this thread for a clever method by Peter Pein in order
> > to get a continuous antiderivative with Mathematica.
>
> You seem to be implying that Peter's method can be used to produce an

> antiderivative, continuous on R, for 1/(5 + Cos[x]). I don't see how. Cou=

Daniel Lichtblau

unread,
Mar 29, 2007, 3:37:06 AM3/29/07
to
Michael Weyrauch wrote:
> Hello,
>
> well, in case that nothing else is available, I am happy with a numerical solution of a problem.
> And that's what NDSolve produces. After all an interpolating function is only a numerical approximation
> to the solution looked for -- admittedly in a form easily worked with.
>
> However, generally, even if it looks complicated
> an analytical solution has its specific virtues. Just assume that one of the constants in the integral
> would actually be a parameter, say a, than I could easily study the parameter dependence of the integral,
> which may produce further insight, e.g. that a certain term may or may not be neglected in the parameter range
> of interest. (That's the way physicists often make progress...)

It's not entirely clear but I believe you are discussing the case of a
parametrized antiderivative, as opposed to a parametrized definite
integral. If so, how is this analysis affected by the presence of a
differential constant in the antiderivative? If not, then it does not
seem to matter; either the entiderivative is correct, or it is not, and
in the former case the analysis can proceed. But this is all independent
of the issue of interval-continuous antiderivatives.


> (By the way I got a few private messages in response to my post in this newsgroup which strongly supported
> the idea that Mathematica should support an option in order to ask for the solution which is
> continouus on the real line.)

Not from anyone who'd actually have to, err, support such a thing.


> So, I conclude, (also from reading some of the papers Dimitris suggested) that there is a genuine point to have
> an explicit (non-numeric) solution of the integral which is continuous and differentiable on the real line if it exists,
> irrespective how complicated it may look.

Clearly such a form may be used a la Newton-Leibniz for computing
definite integrals with bounds on the real line. As has been pointed
out, there are other ways to get such results i.e. by analysis of path
singularities. The latter approach certainly has its weaknesses. But I'm
not convinced the former is always viable either. That is, I have no
idea how to generally construct antiderivatives that are continuous on
some specified interval such as the real axis.


> Nevertheless, your suggestion to use NDSolve spurred my interest, and I tried to use DSolve in order to determine
> the integral. And here is what I got,
>
> (*in*)
> sol = DSolve[Derivative[1][f][x] == (x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17),
>
> f, x]
>
> (*out*)
>
> {{f -> Function[{x}, (1/2)*ArcTan[(-1 - x)/(-4 + x^2)] -
>
> (1/2)*ArcTan[(1 + x)/(-4 + x^2)] + C[1]]}}
>
> It's exactly our good old friend, which is neither continuous nor differentiable at x=2.

Well of course. Did you think DSolve had its own integrator different
from Integrate? Below one sees how Integrate is called from DSolve in
this example.

In[1]:= Unprotect[Integrate];

In[2]:= Integrate[a__] := Null /; (Print[InputForm[int[a]]]; False)

In[3]:= InputForm[DSolve[Derivative[1][f][x] == (x^2 + 2*x + 4)/(x^4 -
7*x^2 + 2*x + 17), f, x]]

int[(4 + 2*x + x^2)/(17 + 2*x - 7*x^2 + x^4), x]

Out[3]//InputForm=
{{f -> Function[{x}, ArcTan[(-1 - x)/(-4 + x^2)]/2 -
ArcTan[(1 + x)/(-4 + x^2)]/2 + C[1]]}}


> But Mathematica even provides an integration constant so as to make me believe that
> this is the solution up to a constant to be determined by an initial condition.
> On the left hand side of my equation there just is
> f', and what I exspected is a differentiable solution. Or can I also here excuse myself with
> singularities in the complex plane?? I definitely thought that DSolve solves differential
> equations of one or more REAL variables. ??

I don't see how it can generally do that. It is not given a specific
interval but only a start point. So solutions are only correct in a
neighborhood of that point. If input involves analytic functions then I
think there is a guarantee that the neighborhood is in the complex plane
(of the independent variable).

I confess I'm out of my area here and there may be issues with singular
curves and the like, so the term "neighborhood" may need to be taken a
bit loosely.


> In contrast, NDSolve exactly does this as Andrzej Kozlowski has shown in his post.
> So, at least, I learn that DSolve and NDSolve do different things (sometimes) apart from
> one being analytical and the other numerical.
> Is that really intended and mathematically sound?

How could their respective goals be otherwise accomplished?

Maybe I do not understand your question.


> I would be grateful for further enlightening.
>
> Cheers Michael Weyrauch

> [...]


Daniel Lichtblau
Wolfram Research


David W.Cantrell

unread,
Mar 30, 2007, 3:55:28 AM3/30/07
to
"dimitris" <dimm...@yahoo.com> wrote:
> Hi.
>
> I apologise for the delay.
>
> I will reply to your questions in this post; but I want the current
> post to serve as a sum up of this beautiful thread. So I apologise also
> for its considerable length and not anwering at once to your queries.

There is certainly no need to apologize.
Congratulations that you are to be a father!

Due to the length of your message, I've removed (snipped) a great deal
below, leaving only the material essentially related to my response.

> f[x_] :== 1/(2 + Cos[x])
>

> The indefinite integral by Mathematica
>
> F[x_] == Integrate[f[x], x]
> (2*ArcTan[Tan[x/2]/Sqrt[3]])/Sqrt[3]

> >From an old book about Mathematica (Mathematica for Scientists and


> Enginners by R. Gass we got (but without further explanation...)
>
> FF[x_] == (-2*3^(1/2)*ArcTan[Sin[x]/(Cos[x] + 1)])/3 +
> (2*3^(1/2)*ArcTan[(3^(1/2)*Sin[x])/(3*(Cos[x] + 1))])/3 +
> (3^(1/2)*x)/3

> as a continuous antiderivative in the real axis.


>
> I will be very glad if you could show me how exactly the author get
> previous antiderivative or what method in general would you follow
> in order to get a continuous antiderivative in the real axis.

Below, I'll show what I suspect that Gass did and also show what I
would then do in this problem.

> It is time to answer your first second question
>
> > Unfortunately, I don't have Trott's book. Since it's very easy to
> > obtain, could you also please show us the continuous
> > antiderivative for
> > 1/(5 + Cos[x]) obtained by Trott's method?
>
> As you see I chose another example (similar to Trott's) because I
> want to show also the continuous antiderivative by Gass' book.
>
> I don't know what you have understood but stating that
>
> > > But in case of recognizing the jump discontinuity and its position,
> > > it is very easy to obtain a continous antiderivative adding the
> > > piecewise constant (see the relevant example from Trott's book!)
>
> I really mean something like
>
> Fc[x_] :== Piecewise[{{F[x], Inequality[-4*Pi, LessEqual, x, Less,
> -3*Pi]}, {Pi/Sqrt[3], x ==== -3*Pi},
> {F[x] + 2*(Pi/Sqrt[3]), -3*Pi < x < -Pi}, {4*(Pi/Sqrt[3]), x
> ==== -
> Pi}, {F[x] + 4*(Pi/Sqrt[3]), -Pi < x < Pi},
> {6*(Pi/Sqrt[3]), x ==== Pi}, {F[x] + 6*(Pi/Sqrt[3]), Pi < x <
> 3*Pi},
> {8*(Pi/Sqrt[3]), x ==== 3*Pi},
> {F[x] + 8*(Pi/Sqrt[3]), Inequality[3*Pi, Less, x, LessEqual,
> 4*Pi]}}]
>
> I hope you are not dissapointed!

To be honest, yes, that is disappointing because it is messy and, more
importantly, it is not an antiderivative valid over the _whole_ real
line.

--------------------------------------

For 1/(2 + Cos[x]), we wish to get an antiderivative which is valid on
R. As you showed (in some of what I snipped), the standard Weierstrass
substitution, u = Tan[x/2], leads to the same antiderivative as that
returned by Mathematica, (2*ArcTan[Tan[x/2]/Sqrt[3]])/Sqrt[3].

The only type of singularity occurs when x = (2n + 1)Pi, n integer. By
looking at the difference between limits from either side of, say, Pi,
we see that these discontinuities are caused by jumps of 2 Pi/Sqrt[3].
To remove those jumps, we may simply add 2 Pi/Sqrt[3] Floor[(x + Pi)/(2 Pi)]
to Mathematica's antiderivative. Let's call this result F1[x]:

(2 ArcTan[Tan[x/2]/Sqrt[3]] + 2 Pi Floor[(x + Pi)/(2 Pi)])/Sqrt[3]

Although F1[x] has no jumps, it is still Indeterminate at x = (2n + 1)Pi.
But these singularities are removable. The only question remaining is how
to remove them "nicely".

Note that 2 Pi Floor[(x + Pi)/(2 Pi)] is the same as x - 2 ArcTan[Tan[x/2]],
except that the latter is Indeterminate at x = (2n + 1)Pi.
Substituting accordingly in F1[x], we get F2[x]:

(2 ArcTan[Tan[x/2]/Sqrt[3]] + x - 2 ArcTan[Tan[x/2]])/Sqrt[3]

This seems no better, and perhaps even worse, than F1[x]. But, simply
noting that Tan[x/2] and Sin[x]/(1 + Cos[x]) are identical, F2[x] is
the result given by Gass. (Of course, whether he obtained his result
by my method, I have no idea.)

We still have removable singularities to get rid of. The trick (which can
perhaps be done with Mathematica, although I don't know how) is to
combine the two arctangents of F2[x] into a single arctangent. Using
just basic trig to do so, F2[x] can be "rewritten" as F3[x]:

(x - 2 ArcTan[Sin[x]/(Cos[x] + 2 + Sqrt[3])])/Sqrt[3]

which is my suggested antiderivative on R. The nice thing is that,
having combined the two former arctangents, each of which was
Indeterminate at x = (2n + 1)Pi, we have gotten rid of the removable
discontinuities, the new single arctangent being defined for all reals.

- - - - -

More generally, for 1/(a + Cos[x]) with a > 1 or a < -1, the above process
can be applied to give an antiderivative valid on R:

(x - 2 ArcTan[Sin[x]/(Cos[x] + a + Sign[a] Sqrt[a^2 - 1])])/(Sign[a] Sqrt[a^2 - 1]).

Kind regards,
David W. Cantrell

P.S. There is a way that F1[x] could be _made_ valid throughout R. One
might suggest that the reason that F1[x] is Indeterminate at x = (2n + 1)Pi
in Mathematica is the presence of Tan[x/2], but I do not agree. Tan[x/2] is
defined for _all_ real x in Mathematica; in particular, at x = (2n + 1)Pi,
its value is ComplexInfinity. The reason that F1[x] is Indeterminate is
that ArcTan[ComplexInfinity] is Indeterminate. That, in my opinion, need
not be the case! ArcTan is, after all, just the principal branch of the
multivalued inverse tangent relation. What we choose to call the principal
branch is, in essence, _arbitrary_. That being the case, what harm would be
done by assigning a value to ArcTan[ComplexInfinity]? Granted,
ArcTan[Infinity] is +Pi/2, while ArcTan[-Infinity] is -Pi/2. But I see no
reason why we could not reasonably choose to say that
ArcTan[ComplexInfinity] is one of those. If we chose
ArcTan[ComplexInfinity] = -Pi/2, then F1[x], as originally given, would be
valid throughout R. If we instead chose ArcTan[ComplexInfinity] = +Pi/2,
then the Floor in F1 would need to be replaced by Ceiling to give us an
antiderivative valid throughout R. My point is that Indeterminate is
a "dead end" which should be avoided when there is a reasonable, even if
arbitrary, way to do so.

dimitris

unread,
Mar 30, 2007, 4:05:39 AM3/30/07
to
This question appeared in my previous post but may be to its length
could stay unnoticed.

Consider the antiderivative of 1/(2+Cos[x]).

f = HoldForm[Derivative[-1][1/(Cos[#1] + 2) & ][x]]

Mathematica returns an antiderivative having a jump discontinuity
at x=Pi in the range [0,2Pi].

F = ReleaseHold[f]
TrigFactor[D[F, x]]
Plot[F, {x, 0, 2*Pi}, Ticks -> {Range[0, 2*Pi, Pi/2], Automatic}]

(2*ArcTan[Tan[x/2]/Sqrt[3]])/Sqrt[3]
1/(2 + Cos[x])

This is normal since the integrand is not analytic in the complex
plane. So any candidate for an antidrivative of this function, will
have to have singularities somewhere in the complex plane.

So the correct application of the Newton Leibniz formula is

(F /. x -> 2*Pi) - Limit[F, x -> Pi, Direction -> -1] + Limit[F, x ->
Pi, Direction -> 1] - (F /. x -> 0)
(2*Pi)/Sqrt[3]

and that precisely does Mathematica.

Integrate[1/(2 + Cos[x]), {x, 0, 2*Pi}]
{N[%], NIntegrate[1/(2 + Cos[x]), {x, 0, 2*Pi}]}

(2*Pi)/Sqrt[3]
{3.6275987284684352, 3.6275987284707627}

One can take a continuous antiderivative in the interval
[0,2Pi] by adding the piecewise constant function:

(Limit[(2*ArcTan[Tan[x/2]/Sqrt[3]])/Sqrt[3], x -> Pi, Direction -> #1]


& ) /@ {-1, 1}

{-(Pi/Sqrt[3]), Pi/Sqrt[3]}

Fc[x_] := Piecewise[{{F, -Pi < x < Pi}, {2*(Pi/Sqrt[3]), x == Pi}, {F
+ 2*(Pi/Sqrt[3]), Pi < x < 3*Pi}}]

Plot[Fc[x], {x, 0, 2*Pi}, Ticks -> {Range[0, 2*Pi, Pi/2], Automatic}]

Fc[2*Pi] - Fc[0]
(2*Pi)/Sqrt[3]

My question now...

>From an old book about Mathematica (Mathematica for Scientists and

Enginners by R. Gass we ge (but without further explanation...)

FF[x_] = (-2*3^(1/2)*ArcTan[Sin[x]/(Cos[x] + 1)])/3 +


(2*3^(1/2)*ArcTan[(3^(1/2)*Sin[x])/(3*(Cos[x] + 1))])/3 +
(3^(1/2)*x)/3

D[FF[x], x]//Simplify

1/(2 + Cos[x])

Plot[FF[x], {x, 0, 2*Pi}, Ticks -> {Range[0, 2*Pi, Pi/2], Automatic}]

as a continuous antiderivative in the real axis for the integrand.

So the Newton-Leibniz formula reads

FF[2*Pi] - FF[0]
(2*Pi)/Sqrt[3]

I know that my question does not have much connection with CAS issues
but can someone explain me how exactly could we take FF[x]?

Is it possible to obtain FF[x] by a CAS following some way?

Thanks a lot.
Dimitris


=CF/=C7 dimitris =DD=E3=F1=E1=F8=E5:

> Show[GraphicsArray[Block[{$DisplayFunction == Identity}, (Plot3D[#1[f=


[x
> + I*y]], {x, -2*Pi, 2*Pi}, {y, -3, 3}] & ) /@ {Re, Im}]], ImageSize ->
> 600];
>

> Show[GraphicsArray[Block[{$DisplayFunction == Identity}, (Plot3D[#1[F=


[x
> + I*y]], {x, -2*Pi, 2*Pi}, {y, -3, 3}] & ) /@ {Re, Im}]], ImageSize ->
> 600];
>
>
> The function f has 4 poles in the complex domain withing the range
> [-4Pi,4Pi]. Indeed
>
> Reduce[Denominator[f[x]] ==== 0 && -4*Pi < Re[x] < 4*Pi, x]
> {ToRules[%]}
> % /. (x_ -> a_) :> x -> ComplexExpand[a]
> Show[Graphics[{PointSize[0.02], (Point[{Re[#1], Im[#1]}] & ) /@ (x /.
> %)}], Axes -> True,
> Ticks -> {Range[-4*Pi, 4*Pi, Pi], Automatic}, AxesLabel -> {"Re",
> "Im"}];
>

> x ==== -2*Pi - ArcCos[-2] || x ==== 2*Pi - ArcCos[-2] || =


x ==== 4*Pi -
> ArcCos[-2] || x ==== -ArcCos[-2] || x ==== ArcCos[-2] ||

> x ==== -4*Pi + ArcCos[-2] || x ==== -2*Pi + ArcCos[-2] =

> > Unfortunately, I don't have Trott's book. Since it's very easy to obtai=


n,
> > could you also please show us the continuous antiderivative for
> > 1/(5 + Cos[x]) obtained by Trott's method?
>
> As you see I chose another example (similar to Trott's) because I want
> to
> show also the continuous antiderivative by Gass' book.
>
> I don't know what you have understood but stating that
>
> > > But in case of recognizing the jump discontinuity and its position, it
> > > is very easy to obtain a continous antiderivative adding the piecewise
> > > constant (see the relevant example from Trott's book!)
>
> I really mean something like
>
> Fc[x_] :== Piecewise[{{F[x], Inequality[-4*Pi, LessEqual, x, Less,
> -3*Pi]}, {Pi/Sqrt[3], x ==== -3*Pi},
> {F[x] + 2*(Pi/Sqrt[3]), -3*Pi < x < -Pi}, {4*(Pi/Sqrt[3]), x ===
== -
> Pi}, {F[x] + 4*(Pi/Sqrt[3]), -Pi < x < Pi},

> {6*(Pi/Sqrt[3]), x ==== Pi}, {F[x] + 6*(Pi/Sqrt[3]), Pi < x <=


3*Pi},
> {8*(Pi/Sqrt[3]), x ==== 3*Pi},
> {F[x] + 8*(Pi/Sqrt[3]), Inequality[3*Pi, Less, x, LessEqual,
> 4*Pi]}}]
>
> I hope you are not dissapointed!
>
> Plot[Fc[x], {x, -4*Pi, 4*Pi}]
>
> Plot[{FF[x], F[x], Fc[x]}, {x, -4*Pi, 4*Pi}, PlotStyle -> {Red, Blue,
> Green}];
>
> Of course
>
> Fc[4*Pi] - Fc[-4*Pi]
> (8*Pi)/Sqrt[3]
>
> But I am quite sure even if you are not dissapointed you will be right
> now!
>
> > You seem to be implying that Peter's method can be used to produce an

> > antiderivative, continuous on R, for 1/(5 + Cos[x]). I don't see how. C=

> > antiderivative, continuous on R, for 1/(5 + Cos[x]). I don't see how. C=


ou=
> ld
> > you please show us?
> >
> > > But in case of recognizing the jump discontinuity and its position, it
> > > is very easy to obtain a continous antiderivative adding the piecewise
> > > constant (see the relevant example from Trott's book!)
> >

> > Unfortunately, I don't have Trott's book. Since it's very easy to obtai=

dimitris

unread,
Mar 30, 2007, 4:06:40 AM3/30/07
to
> Back in December, in the thread which led to this one, I gave an
> antiderivative which is continuous along the whole real line:
>
> ArcTan[(4x + Sqrt[2(15 + Sqrt[241])])/(2 - Sqrt[2(-15 + Sqrt[241])])] +
> ArcTan[(4x - Sqrt[2(15 + Sqrt[241])])/(2 + Sqrt[2(-15 + Sqrt[241])])]

Could we show me how you get this antiderivative for the integrand

f[x_] = (x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17);

BTW,

Using Mathematica I was able to get a continuous in the real axis
antiderivative as follows

Times @@ Apply[#1[[1]] - #1[[2]] & , Solve[Denominator[f[x]] == 0, x],

1];
Apart[(4 + 2*x + x^2)/%];
Map[FullSimplify, %, 1];
(Integrate[#1, x] & ) /@ %;
FF[x_] = FullSimplify[%]
FullSimplify[D[FF[x], x] == f[x]]

(1/4)*(-2*ArcTan[(2*x)/(-1 + Sqrt[-15 - 4*I])] + 2*ArcTan[(2*x)/(1 +
Sqrt[-15 - 4*I])] -
2*ArcTan[(2*x)/(-1 + Sqrt[-15 + 4*I])] + 2*ArcTan[(2*x)/(1 +
Sqrt[-15 + 4*I])] -
I*(Log[(7 + 2*I) + Sqrt[-15 - 4*I] - 2*x^2] - Log[(7 - 2*I) +
Sqrt[-15 + 4*I] - 2*x^2] +
Log[(-7 - 2*I) + Sqrt[-15 - 4*I] + 2*x^2] - Log[(-7 + 2*I) +
Sqrt[-15 + 4*I] + 2*x^2]))
True

Plot[FF[x], {x, 0, 4}]


Thanks a lot!
Dimitris

=CF/=C7 David W.Cantrell =DD=E3=F1=E1=F8=E5:


> "Michael Weyrauch" <michael....@gmx.de> wrote:
> > Hello,
> >
> > another nice example, where the result for the integral given by
> > Mathematica just cannot be right.
>

> I understand your point, but it's impossible to have a result here which
> is "right" throughout the complex plane.
>

> > The indefinite integral of a continuuos function cannot have a jump.
>

> Again, I understand your point. You're thinking just about integrating
> along the real line; the integrand
>
> (x^2 + 2x + 4)/(x^4 - 7x^2 + 2x + 17)
>
> is indeed continuous there. But computer algebra systems sometimes give
> antiderivatives which are "right" only piecewise. You're welcome to

> consider that unfortunate in this case because we can do better; see belo=
w=2E


>
> > That -- to my opinion -- is mathematical
> > nonsens. We all learned that integration "smoothens", i.e. if the
> > integrand is somewhat "ugly" the integral is less "ugly". (Never mind my
> > English!).
> >
> > So the result should actually be presented as
> >
> > F[x_]=ArcTan[(1 + x)/(4 - x^2)]*UnitStep[2 - x] +
> > (Pi + ArcTan[(1 + x)/(4 - x^2)])*UnitStep[-2 + x]
>

> No, not if you're wanting an antiderivative valid along the whole real
> line. Your F has a jump discontinuity at x = -2. Furthermore, it is
> Indeterminate at x = +2, although that singularity is removable.
>
> Back in December, in the thread which led to this one, I gave an
> antiderivative which is continuous along the whole real line:
>
> ArcTan[(4x + Sqrt[2(15 + Sqrt[241])])/(2 - Sqrt[2(-15 + Sqrt[241])])] +
> ArcTan[(4x - Sqrt[2(15 + Sqrt[241])])/(2 + Sqrt[2(-15 + Sqrt[241])])]
>
> David W. Cantrell
>

> > This is a perfectly nice function without jumps and it is the

> > antiderivative of your integrand, and the fundamental theorem of calcul=
us

> > > {{0, 0}, {ArcTan[Sqrt[2/3]]/Sqrt[6], ArcTan[Sqrt[2/3]]/Sqrt[6]}, {-(P=


i/
> > > (2*Sqrt[6])), Pi/(2*Sqrt[6])},
> > > {-(ArcTan[Sqrt[2/3]]/Sqrt[6]), -(ArcTan[Sqrt[2/3]]/Sqrt[6])}, {0,
> > > 0}}
> > >
> > > Reduce[5 + Cos[x] == 0 && 0 <= Re[x] <= 4*Pi, x]
> > > {ToRules[%]} /. (x_ -> b_) :> x -> ComplexExpand[b]
> > > x /. %;
> > > ({Re[#1], Im[#1]} & ) /@ %;
> > > poi = Point /@ %;
> > >

> > > x == 2*Pi - ArcCos[-5] || x == 4*Pi - ArcCos[-5] || x == =

David W.Cantrell

unread,
Mar 31, 2007, 2:30:21 AM3/31/07
to

I _already_ showed, in my previous post in this thread, one way to obtain
the result given by Gass. Furthermore, that method could indeed be
automated for a CAS.

Also please note (because you continue to say otherwise) that the result
given by Gass is NOT "a continuous antiderivative in the real axis for the
integrand" as far as Mathematica is concerned. That's due to his expression
being Indeterminate when x = (2n + 1)Pi, n integer.

My previous post, however, gave an antiderivative which IS valid
throughout R.

David

dimitris

unread,
Mar 31, 2007, 2:31:23 AM3/31/07
to
David,

I really appreciate your assistance!

Thanks a lot both for your integration insight and as well your
wishes!

Kind Regards

Dimitris

=CF/=C7 dimitris =DD=E3=F1=E1=F8=E5:

> > consider that unfortunate in this case because we can do better; see be=


lo=
> w=2E
> >
> > > That -- to my opinion -- is mathematical
> > > nonsens. We all learned that integration "smoothens", i.e. if the

> > > integrand is somewhat "ugly" the integral is less "ugly". (Never mind=


my
> > > English!).
> > >
> > > So the result should actually be presented as
> > >
> > > F[x_]=ArcTan[(1 + x)/(4 - x^2)]*UnitStep[2 - x] +
> > > (Pi + ArcTan[(1 + x)/(4 - x^2)])*UnitStep[-2 + x]
> >
> > No, not if you're wanting an antiderivative valid along the whole real
> > line. Your F has a jump discontinuity at x = -2. Furthermore, it is
> > Indeterminate at x = +2, although that singularity is removable.
> >
> > Back in December, in the thread which led to this one, I gave an
> > antiderivative which is continuous along the whole real line:
> >
> > ArcTan[(4x + Sqrt[2(15 + Sqrt[241])])/(2 - Sqrt[2(-15 + Sqrt[241])])] +
> > ArcTan[(4x - Sqrt[2(15 + Sqrt[241])])/(2 + Sqrt[2(-15 + Sqrt[241])])]
> >
> > David W. Cantrell
> >
> > > This is a perfectly nice function without jumps and it is the

> > > antiderivative of your integrand, and the fundamental theorem of calc=


ul=
> us
> > > works with it...
> > >
> > > So, despite my love for Mathematica, here it fools me....
> > >
> > > Regards Michael
> > >
> > > "dimitris" <dimm...@yahoo.com> schrieb im Newsbeitrag
> > > news:etqo3f$10i$1...@smc.vnet.net...
> > > > Hello to all of you!
> > > >
> > > > Firstly, I apologize for the lengthy post!
> > > > Secondly, this post has a close connection with a recent (and well
> > > > active!)

> > > > thread titled "Integrate" and one old post of mine which was based =
on
> > > > a older
> > > > post of David Cantrell. Since there was no response and I do consid=


er
> > > > the
> > > > subject very fundamental I would like any kind of insight.
> > > >
> > > > In the section about Proper Integrals in his article, Adamchik
> > > > mentions that the Newton-Leibniz formula (i.e. the Fundamental
> > > > Theorem of Integral Calculus: Integrate[f[x],{x,a,b}]=F[b]-F[a],
> > > > F[x]: an antiderivative), does not hold any longer if the
> > > > antiderivative F(x) has singularities in the integration interval
> > > > (a,b).
> > > >
> > > > To demonstrate this, he considers the integral of the function:
> > > >
> > > > f[x_] = (x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17);
> > > >
> > > > over the interval (0,4).
> > > >
> > > > Plot[f[x], {x, 0, 4}];
> > > > (*plot to be displayed*)
> > > >
> > > > The integrand posseses no singularities on the interval (0,4).
> > > >
> > > > Here is the corresponding indefinite integral
> > > >
> > > > F[x_] = Simplify[Integrate[f[x], x]]
> > > > ArcTan[(1 + x)/(4 - x^2)]
> > > >
> > > > Substituting limits of integration into F[x] yields an incorrect
> > > > result
> > > >

> > > > Limit[F[x], x -> 4, Direction -> 1] - Limit[F[x], x -> 0, Direction=


-
> > > >>1]
> > > > N[%]
> > > > NIntegrate[f[x], {x, 0, 4}]
> > > >
> > > > -ArcTan[1/4] - ArcTan[5/12]
> > > > -0.6397697828266257
> > > > 2.501822870767894
> > > >
> > > > This is because the antiderivative has a jump discontinuity at x=2
> > > > (also at x = -2), so that the Fundamental theorem cannot be used.
> > > >
> > > > Indeed
> > > >
> > > > Limit[F[x], x -> 2, Direction -> #1]&/@{-1, 1}
> > > > Show@Block[{$DisplayFunction=Identity},
> > > > Plot[F[x],{x,#[[1]],#[[2]]}]&/@Partition[Range[0,4,2],2,1]];
> > > > {-(Pi/2), Pi/2}
> > > > (*plot to be displayed*)
> > > >
> > > > The right way of applying the Fundamental theorem is the following
> > > >

> > > > (Limit[F[x], x -> 4, Direction -> 1] - Limit[F[x], x -> 2, Directio=


n -
> > > >> -1]) +

> > > > (Limit[F[x], x -> 2, Direction -> 1] - Limit[F[x], x -> 0, Directi=

> > > > Table[(Limit[F[x], x -> n*(Pi/2), Direction -> #1] & ) /@ {-1, 1}, =
{n,
> > > > 0, 4}]
> > > > {{0, 0}, {ArcTan[Sqrt[2/3]]/Sqrt[6], ArcTan[Sqrt[2/3]]/Sqrt[6]}, {-=


(P=
> i/
> > > > (2*Sqrt[6])), Pi/(2*Sqrt[6])},
> > > > {-(ArcTan[Sqrt[2/3]]/Sqrt[6]), -(ArcTan[Sqrt[2/3]]/Sqrt[6])}, {0,
> > > > 0}}
> > > >
> > > > Reduce[5 + Cos[x] == 0 && 0 <= Re[x] <= 4*Pi, x]
> > > > {ToRules[%]} /. (x_ -> b_) :> x -> ComplexExpand[b]
> > > > x /. %;
> > > > ({Re[#1], Im[#1]} & ) /@ %;
> > > > poi = Point /@ %;
> > > >
> > > > x == 2*Pi - ArcCos[-5] || x == 4*Pi - ArcCos[-5] || x ==
= =
> ArcCos[-5] ||
> > > > x == 2*Pi + ArcCos[-5]

> > > > {{x -> Pi - I*Log[5 - 2*Sqrt[6]]}, {x -> 3*Pi - I*Log[5 - 2*Sqrt[6]=


]},
> > > > {x -> Pi + I*Log[5 - 2*Sqrt[6]]},
> > > > {x -> 3*Pi + I*Log[5 - 2*Sqrt[6]]}}
> > > >
> > > > Of course F[4Pi]-F[0]=0 incorrectly.
> > > >
> > > > The reason for the discrepancy in the above result is not because of

> > > > any problem with the fundamental theorem of calculus, of course; it=


is
> > > > caused by the multivalued nature of the indefinite integral arctan.
> > > >
> > > >
> > > > Show[GraphicsArray[Block[{$DisplayFunction = Identity},

> > > > (ContourPlot[#1[F[x + I*y]], {x, 0, 4*Pi}, {y, -4, 4}, Contours =

David W.Cantrell

unread,
Mar 31, 2007, 2:38:03 AM3/31/07
to
"dimitris" <dimm...@yahoo.com> wrote:
> > Back in December, in the thread which led to this one, I gave an
> > antiderivative which is continuous along the whole real line:
> >
> > ArcTan[(4x + Sqrt[2(15 + Sqrt[241])])/(2 - Sqrt[2(-15 + Sqrt[241])])] +
> > ArcTan[(4x - Sqrt[2(15 + Sqrt[241])])/(2 + Sqrt[2(-15 + Sqrt[241])])]
>
> Could we show me how you get this antiderivative for the integrand
>
> f[x_] = (x^2 + 2*x + 4)/(x^4 - 7*x^2 + 2*x + 17);

Let's begin with Mathematica's own antiderivative:


ArcTan[(1 + x)/(4 - x^2)]

Recalling that tan(p + q) = (tan(p) + tan(q))/(1 - tan(p)tan(q)),
let's rewrite (1 + x)/(4 - x^2) in the form
((a*x + b) + (c*x + d))/(1 - (a*x + b)*(c*x + d))
because that will allow us to break apart Mathematica's antiderivative
into a sum of two arctangents having arguments which are _always real_.

In[9]:=
ArcTan[a*x + b] + ArcTan[c*x + d] /. FullSimplify[SolveAlways[
(1 + x)/(4 - x^2) == ((a*x + b) + (c*x + d))/(1 - (a*x + b)*(c*x + d)),
x][[3]]]

Out[9]=
ArcTan[Root[-1 + 15*#1 - 58*#1^2 - 17*#1^3 + 3*#1^4 & , 1] +
x*Root[4 - 8*#1 + 21*#1^2 - 17*#1^3 + 3*#1^4 & , 1]] +
ArcTan[Root[-1 + 15*#1 - 58*#1^2 - 17*#1^3 + 3*#1^4 & , 2] +
x*Root[4 - 8*#1 + 21*#1^2 - 17*#1^3 + 3*#1^4 & , 2]]

Out[9] is equivalent to the continuous antiderivative which I'd given
previously. The process I used to obtain it here could be automated. The
only thing that probably seems mysterious above is why I chose the _third_
solution in particular. Explanation:

SolveAlways returned six solutions. In the first two of those, a and c were
zero, and so those two were not valid. In the last two of those, we got
complex quantities; either of those could in fact have been used, but I
preferred an expression where everything was real. The middle two solutions
involved real quantities only. I could just as well have chosen to use the
fourth solution, instead of the third; doing so would also have produced a
continuous antiderivative equivalent to that which I'd given previously.

David

0 new messages