Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Definite Integration in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74634] Re: Definite Integration in Mathematica
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Thu, 29 Mar 2007 02:30:34 -0500 (EST)

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" <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[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=
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 obtain,
> 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: Solving a nasty rational differential equation
  • Next by Date: Re: Is this a problem in mathematica?
  • Previous by thread: Re: Definite Integration in Mathematica
  • Next by thread: Re: Definite Integration in Mathematica