       Re: Definite Integration in Mathematica (continuous antiderivative from Gass' book)

• To: mathgroup at smc.vnet.net
• Subject: [mg74666] Re: Definite Integration in Mathematica (continuous antiderivative from Gass' book)
• From: "dimitris" <dimmechan at yahoo.com>
• Date: Fri, 30 Mar 2007 03:00:31 -0500 (EST)
• References: <eufq77\$7hj\$1@smc.vnet.net>

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])/Sqrt
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

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.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])/Sqrt, x -> Pi, Direction -> #1]
& ) /@ {-1, 1}
{-(Pi/Sqrt), Pi/Sqrt}

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

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

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

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
(2*Pi)/Sqrt

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:
> 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])/Sqrt
>
> Check
>
> Simplify[D[F[x], x] ==== f[x]]
> True
>
> Its plot
>
> Show[Block[{\$DisplayFunction == Identity}, (Plot[F[x], {x, #1[],
> #1[]}, 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]}, {x -> Pi - I*Log[2 - Sqrt]}, {x
> -> 3*Pi - I*Log[2 - Sqrt]},
>   {x -> -Pi - I*Log[2 - Sqrt]}, {x -> Pi + I*Log[2 - Sqrt]}, {x -
> > -3*Pi + I*Log[2 - Sqrt]},
>   {x -> -Pi + I*Log[2 - Sqrt]}, {x -> 3*Pi + I*Log[2 - Sqrt]}}
> (*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), Pi/Sqrt}, {0, 0}, {-(Pi/Sqrt), Pi/
> Sqrt}, {0, 0}, {-(Pi/Sqrt), Pi/Sqrt}, {0, 0},
>   {-(Pi/Sqrt), Pi/Sqrt}, {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
> {14.510394913873741, 14.510394913883049}
>
> Obviously
>
> (Integrate[f[x], {x, #1[], #1[]}] & ) /@ Partition[Range[-4*Pi,
> 4*Pi, Pi], 2, 1]
> Tr[%]
>
> {Pi/Sqrt, Pi/Sqrt, Pi/Sqrt, Pi/Sqrt, Pi/Sqrt, Pi/
> Sqrt, Pi/Sqrt, Pi/Sqrt}
> (8*Pi)/Sqrt
>
> 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[]}, 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])/Sqrt
> (2*ArcTan[Tan[x/2]/Sqrt])/Sqrt
> 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 - (2*ArcTan[Sin[x]/(1 + Cos[x])])/Sqrt + (2*ArcTan[Sin[x]/
> (Sqrt*(1 + Cos[x]))])/Sqrt
> 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 - (2*(Cos[x]/(1 + Cos[x]) + Sin[x]^2/(1 + Cos[x])^2))/
> (Sqrt*(1 + Sin[x]^2/(1 + Cos[x])^2)) +
>   (2*(Cos[x]/(Sqrt*(1 + Cos[x])) + Sin[x]^2/(Sqrt*(1 +
> Cos[x])^2)))/(Sqrt*(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
> (8*Pi)/Sqrt
>
> It is time to answer your first second question
>
> > 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, x ==== -3*Pi},
>     {F[x] + 2*(Pi/Sqrt), -3*Pi < x < -Pi}, {4*(Pi/Sqrt), x ===
== -
> Pi}, {F[x] + 4*(Pi/Sqrt), -Pi < x < Pi},
>     {6*(Pi/Sqrt), x ==== Pi}, {F[x] + 6*(Pi/Sqrt), Pi < x <=
3*Pi},
> {8*(Pi/Sqrt), x ==== 3*Pi},
>     {F[x] + 8*(Pi/Sqrt), 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
>
> 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=
ou=
> 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" <dimmechan at 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
> > >
> > > 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. 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=
n,
> > could you also please show us the continuous antiderivative for
> > 1/(5 + Cos[x]) obtained by Trott's method?
> >
> > David W. Cantrell

• Prev by Date: Re: Definite Integration in Mathematica
• Next by Date: RE: ReadList
• Previous by thread: Re: Netlink Net Framework
• Next by thread: Re: Definite Integration in Mathematica (continuous antiderivative from Gass' book)