MathGroup Archive 2007

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

Search the Archive

(more in) Integrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74287] (more in) Integrate
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Sat, 17 Mar 2007 02:03:56 -0500 (EST)
  • References: <esls78$q0v$1@smc.vnet.net><etb5a5$k14$1@smc.vnet.net>

> > Nevertheless, in the present situation I do not really understand why
> >Mathematica wants me to do that rather trivial variable transformation,
>>which is at the heart of your solution.

As we saw your original integral with a trivial transformation became
very easily computed
by Mathematica. In a attempt to explain the behavior of Integrate I
connect it with the partial
fraction decomposition, PFC.

Let think reversely now. My goal is not to show if I was right about
my guessing about PFC but rather
than to demonstrate that using a transformation of the integration
variable inside a known integral allows
to find examples of doable, but not done, integrals by Mathematica
(the example-and just this! For
anything bad or good mentioned below I am responsible for!-is adopted
by M. Trott's Guidebook for
Symbolics). In this way, I believe you will understand that the
behavior of Integrate in your integral and in
contrast to the same integral after my transformation is (to some
extent of course!) "normal".

So let

f = HoldForm[Integrate[Cos[x] Exp[-x^2], {x, -Infinity, Infinity}]];

The integral is trivial for Mathematica as the following show

f=HoldForm[Integrate[Cos[x] Exp[-x^2],{x,-Infinity,Infinity}]];

ReleaseHold[f] (*analytic result*)
{%//N[#,10]&,f/.Integrate[x___]:>NIntegrate[x, PrecisionGoal -> 10,
  WorkingPrecision -> 20]//ReleaseHold(*numerical result*)}

Sqrt[Pi]/E^(1/4)
{1.380388447,1.380388447}

However change x now to x-1/x (the so called Cauchy transformation).

{ReleaseHold[Replace[f, x -> -x^(-1) + x, {4, Infinity}]]//
InputForm,Replace[
            f/.Integrate[x___]:>NIntegrate[x, PrecisionGoal -> 10,
WorkingPrecision -> 20],x -> -x^(-1) + x,{4,=E2=88=9E}]//ReleaseHold}
{Integrate[Cos[x^(-1) - x]/E^(-x^(-1) + x)^2, {x, -Infinity,
Infinity}],1.3803884470}

results in an integral that it is doable (as the numarical integration
indicates!) but not done
by Mathematica symbolically.

However

FullSimplify[(Cos[x^(-1) - x]/E^(-x^(-1) + x)^2 /. x -> -x) ==
Cos[x^(-1) - x]/E^(-x^(-1) + x)^2]
True

so the integrand is an even function of x.
So that (the form of the integrand let you use this argument!)

HoldForm[Integrate[Cos[x^(-1) - x]/E^(-x^(-1) + x)^2, {x, -Infinity,
Infinity}] == 2Integrate[Cos[x^(-1) -
      x]/E^(-x^(-1) + x)^2, {x, 0, Infinity}]]

Following next the following procedure the integral can now be done!

integrand = 2*(Cos[1/x - x]/E^(-(1/x) + x)^2)*dx
Solve[x - 1/x == u, x]
{Limit[x - 1/x, x -> 0, Direction -> -1], Limit[x - 1/x, x ->
Infinity, Direction -> 1]}
integrand2 = FullSimplify[integrand /. %%[[2]] /. dx -> D[(x /. %%)
[[2]], u]]
Integrate[integrand2, {u, -Infinity, Infinity}]

(2*dx*Cos[1/x - x])/E^(-(1/x) + x)^2
{{x -> (1/2)*(u - Sqrt[4 + u^2])}, {x -> (1/2)*(u + Sqrt[4 + u^2])}}
{-Infinity, Infinity}
((u + Sqrt[4 + u^2])*Cos[u])/(E^u^2*Sqrt[4 + u^2])
Sqrt[Pi]/E^(1/4)


Best Regards
Dimitris

P=2ES.

Look also the following link for additional material regarding
Integrate:

support.wolfram.com/mathematica/kernel/Symbols/System/Integrate


=CE=9F/=CE=97 dimitris =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5:
> >   Dimitris, this is a marvelous solution to my problem. I really apprec=
ia=
> te
> > your help. I will now see if I can solve all my other (similar) integra=
ls=
>  using the same trick.
>
> It gives me great pleasure that you found so helpful my response.
>
> > Timing is not really the big issue if I get results in a reasonable amo=
un=
> t of time.
>
> Note that you must clarify to your mind what is actually a "reasonable
> amount of time".
> For example on my machine I do believe that the almost 17 seconds for
> evaluating the
> integral with my trick is more than just reasonable time.
>
> Note e.g. a very interesting example
>
> Integrate[BesselJ[0, x]/Sqrt[1 + x^2], {x, 0, Infinity}]//Timing
> N@%[[2]]
> NIntegrate[BesselJ[0, x]/Sqrt[1 + x^2], {x, 0, Infinity}, Method -> \
> Oscillatory]
>
> {4.186999999999999*Second, BesselI[0, 1/2]*BesselK[0, 1/2]}
> 0=2E9831043098467616
> 0=2E9831043098470272
>
> Quit
>
> Integrate[BesselJ[0, x]/Sqrt[1 + x^2], {x, 0, Infinity},
> GenerateConditions -> False]//Timing
> {0.31299999999999994*Second, BesselI[0, 1/2]*BesselK[0, 1/2]}
>
> If you know indepently that the integral converges why leave
> Mathematica to do the "dirty job"
> causing waste of your invaluable time?
>
> > Also the references you cited are quite interesting, because they give =
so=
> me insight
> > what might go on inside Mathematica concerning integration.
>
> Here is a more complete list.
> Note that following the moderator's advice I will avoid the use of
> link references.
>
> "Indefinite and Definite Integration" by Kelly Roach (1992)
> "The evaluation of Bessel functions via G-function identities" by
> Victor Adamchik (1995)
> "Definite Integration in Mathematica 3.0" by the same author
> "Symbolic Definite Integration" by Daniel Lichtblau
>
> Check also
>
> Manuel Bronstein's Symbolic Integration 1 and some references therein.
>
> > I also agree with you that it is my task as a programmer to "help" Math=
em=
> atica
> > and guide it into the direction I want it to go. Sometimes this is an "=
ar=
> t"...
>
> It is an a combination of art, experience, reading, thinking (and
> guessing sometimes!).
>
> Let look an integral appeared in an old post Peter Pein.
>
> $Version
> 5=2E2 for Microsoft Windows (June 20, 2005)
>
> Integrate[Log[Sin[x]^2]*Tan[x], {x, 0, Pi}]
> Integrate::idiv: Integral of Log[Sin[x]^2]*Tan[x] does not converge on
> \
> {x,0,Pi}.
> Integrate[Log[Sin[x]^2]*Tan[x], {x, 0, Pi}]
>
> Of course the integral is zero as you can figure out from the plot of
> the integrand
> in integration range or noticing that f[x]+f[Pi-x]=0 where
>
> f[x_] := Log[Sin[x]^2]*Tan[x]
>
> Also a direct numerical integration verify our statement.
>
> Tr@(NIntegrate[Log[Sin[x]^2]*Tan[x],
> {x,#[[1]],#[[2]]},WorkingPrecision->
>           50,PrecisionGoal->40] &/@Partition[Range[0,Pi,Pi/2],2,1])
> 0``39.9568146932663
>
> It is interesting to see what I got from another CAS (due to the
> policy
> of the forum I can't mention its name).
>
> int(log(sin(x)^2)*tan(x),x=0..Pi);
> undefined
>
> int(log(sin(x)^2)*tan(x),x=0..Pi/2);
> -Infinity
>
> int(log(sin(x)^2)*tan(x),x=Pi/2..Pi);
> Infinity
>
> On the contrary Mathematica may give a wrong value for the
> definite integral in the whole range (0,Pi) but
>
> Integrate[Log[Sin[x]^2]*Tan[x], {x, 0, Pi/2}]
> -(Pi^2/12)
>
> Integrate[Log[Sin[x]^2]*Tan[x], {x, Pi/2, Pi}]
> Pi^2/12
>
> Their sum give zero as it should be!
>
> What is happening here? I will try to figure out (I am not quite sure
> and as you may notice
> I have a recent post mentioning this integral).
>
> Note first that Mathematica evaluates correctly an indefinite integral
> of Log[Sin[x]^2]*Tan[x]
>
> F[x_] = Integrate[f[x], x]
> Log[Sec[x/2]^2]^2 + 2*Log[Sec[x/2]^2]*Log[(1/2)*Cos[x]*Sec[x/2]^2] +
> Log[Sec[x/2]^2]*Log[Sin[x]^2] -
>   2*Log[Sec[x/2]^2]*Log[-1 + Tan[x/2]^2] - Log[Sin[x]^2]*Log[-1 +
> Tan[x/2]^2] + Log[Tan[x/2]^2]*Log[-1 + Tan[x/2]^2] + 2*PolyLog[2,
> (1/2)*Sec[x/2]^2] + PolyLog[2, Cos[x]*Sec[x/2]^2] + PolyLog[2, -Tan[x/
> 2]^2]
>
> Simplify[D[F[x], x] == f[x]]
> True
>
> The obtained antiderivative has real and imaginary part
>
> Plot[Re@F[x], {x, 0, Pi}]
> Plot[Im@F[x], {x, 0, Pi}]
>
> Helping now Mathematica we can take the correct answer
>
> FullSimplify[(Limit[F[x], x -> Pi, Direction -> 1] - Limit[F[x], x ->
> Pi/2, Direction -> -1]) +
>    (Limit[F[x], x -> Pi/2, Direction -> 1] - Limit[F[x], x -> 0,
> Direction -> -1])]
> 0
>
> The problem is the vanishing of the integrand at Pi/2.
>
> Indeed using the following undocumentated setting of Integrate (which
> is well documentated for NIntegrate) Mathematica gives again the
> correct
> answer with less effort
>
> Integrate[Log[Sin[x]^2]*Tan[x], {x, 0, Pi/2, Pi}]
> 0
>
> Note that if we didn't take notice of Pi/2 and applied blindly the
> fundamental
> theorem of calculus we would get incorrectly
>
> FullSimplify[Limit[F[x], x -> Pi, Direction -> 1] - Limit[F[x], x ->
> 0, Direction -> -1]]
> 4*I*Pi*Log[2]
>
> That is a complex value for an integral whose integrand is real in the
> integration range.
> If Mathematica would simply return this complex value, I would say
> that it failed
> to detect the discontinuity of the antiderivative at Pi/2. But it
> returns a warning
> message for divergence, so...I GIVE UP!
>
> Note also that Integrate has been already from version 3.0 very
> powerful.
> But since version 5.0 symbolic integration has become one of the most
> important advantages of Mathematica over other CAS.
>
> But as Daniel Lichtblau pointed out in his article: The powerfulness
> has the price
> of slower speed (usually) and some level of platform dependent
> behavior (less usually)
> than in the past.
>
> Indeed in the original thread regarding this integral there was the
> following response
> from Bob Hanlon:
>
> >>Works in my version:
>
> >>$Version
> >>5.2 for Mac OS X (June 20, 2005)
>
> >>f[x_]:=Log[Sin[x]^2]Tan[x];
>
> >>Integrate[f[x],{x,0,Pi}]
> >>0
>
> Anyway other possible ways of working under Mathematica 5.2 for
> Windows include
>
> Tr @( Integrate[f[x], {x, #1[[1]], #1[[2]]}] &  /@
> Partition[Range[0, Pi, Pi/2], 2, 1] )
> 0
>
> Integrate[f[x], {x, 0, z}, Assumptions -> Inequality[Pi/2, Less, z,
> LessEqual, Pi]]
> Limit[%, z -> Pi, Direction -> 1]
> -(Pi^2/3) - 2*I*Pi*Log[2] + Log[2]^2 + 4*I*Pi*Log[Sec[z/2]] + 4*Log[-
> (Cos[z]/(1 + Cos[z]))]*Log[Sec[z/2]] + 4*Log[Sec[z/2]]^2 -
>   4*Log[Sec[z/2]]*Log[(-Cos[z])*Sec[z/2]^2] + 4*Log[Sec[z/
> 2]]*Log[Sin[z]] - 2*Log[(-Cos[z])*Sec[z/2]^2]*Log[Sin[z]] +
>   2*Log[(-Cos[z])*Sec[z/2]^2]*Log[Tan[z/2]] + 2*PolyLog[2, 1/(1 +
> Cos[z])] + PolyLog[2, Cos[z]*Sec[z/2]^2] +
>   PolyLog[2, -Tan[z/2]^2]
> 0
>
> Assuming[a >= 1, Integrate[f[a*x], {x, 0, Pi}]]
> Limit[%, a -> 1]
>
> (1/(3*a))*(-Pi^2 - 6*I*Pi*Log[2] + 3*Log[2]^2 + 6*Log[Cos[a*Pi]/(1 +
> Cos[a*Pi])]*Log[Sec[(a*Pi)/2]^2] +
>    3*Log[Sec[(a*Pi)/2]^2]^2 + 3*Log[Sec[(a*Pi)/2]^2]*Log[Sin[a*Pi]^2]
> - 6*Log[Sec[(a*Pi)/2]^2]*Log[-1 + Tan[(a*Pi)/2]^2] -
>    3*Log[Sin[a*Pi]^2]*Log[-1 + Tan[(a*Pi)/2]^2] + 3*Log[Tan[(a*Pi)/
> 2]^2]*Log[-1 + Tan[(a*Pi)/2]^2] +
>    6*PolyLog[2, 1/(1 + Cos[a*Pi])] + 3*PolyLog[2, Cos[a*Pi]*Sec[(a*Pi)/
> 2]^2] + 3*PolyLog[2, -Tan[(a*Pi)/2]^2])
> 0
>
> Integrate[f[x], {x, 0, Pi}, GenerateConditions -> False]
> 0
>
> You think and act properly. That is the correct attitude!
>
> > Nevertheless, in the present situation I do not really understand why M=
at=
> hematica wants
> > me to do that rather trivial variable transformation, which is at the h=
ea=
> rt of your solution.
> > The integrand is still a rather complicated rational function of the sa=
me=
>  order. The form
> > of the integrand did not really change
> > substantially as it is the case with some other ingenious substitutions=
 o=
> ne uses in order to
> > do some complicated looking integrals "by hand".
>
> I agree with you. But I can't provide you more insight than I did
> provide you in my original post.
> I think helping in this way Mathematica makes the application of
> partial fraction decomposition
> which is the heart of Risch Algorithm more easily for Integrate. If we
> could understand all of
> Mathematica's Integrate implementation algorithm we will probably work
> at WRI!
>
> I agree also that the the variable transformation is rather trivial.
> But who tells we must not think
> simple things first in order to assist CASs?
>
> Of course we can think and less trivial valiable transformations!
> For example in above mentioned integral:
>
> integrand = f[x]*dx /. x -> ArcSin[Sqrt[u]] /. dx ->
> D[ArcSin[Sqrt[u]], u]
> Integrate[integrand, {u, 0, Sin[Pi]^2}]
>
> Log[u]/(2*(1 - u))
> 0
>
> And what is more important as Peter Pein show in his original post in
> this way
> we can get a more simplified indefinite integral than Mathematica and
> is real in the
> whole integration range.
>
> inintegrand = f[x]*dx /. x -> -ArcSin[Sqrt[u]] /. dx -> D[-
> ArcSin[Sqrt[u]], u]
> Integrate[integrand, {u, 0, Sin[z]^2}, Assumptions -> 0 < z < Pi]
> Plot[%, {z, 0, Pi}]
> (%% /. z -> Pi) - (%% /. z -> 0)
> (D[%%%, z] // Simplify) /. z -> x
>
> Log[u]/(2*(1 - u))
> (1/12)*(-Pi^2 + 6*PolyLog[2, Cos[z]^2])
> (*plot to be displayed*)
> 0
> Log[Sin[x]^2]*Tan[x]
>
>
> > I think the fact that we are forced to such tricks shows that the Mathe=
ma=
> tica integrator
> > is still a bit "immature" in special cases, as also the very interestin=
g =
> article by D. Lichtblau,
> > which you cite, seems to indicate. So all this is probably perfectly kn=
ow=
> n to the
> > Mathematica devellopers. And I hope the next Mathematica version has al=
l =
> this "ironed out"??
>
> Reading again the article.
> Bear in your mind that the subject of the symbolic (indefinite and
> definite) integration
> is perhaps the most serious challenge for all CASs and of course
> Mathematica.
> You can't accuse Mathematica of immaturity even in special cases. If
> you think
> that your integral is a trivial one for a CAS (you don't certainly
> want to see what output I
> got for another CAS!) note Mathematica almost fifteen (yes only 15!)
> ago prior to the quite
> revolutionary version 3.0 it will return -3/2 for the following
> integral
>
> Integrate[1/x^2, {x, -1, 2}]
>
> that is, it would have failed to detect at first stage the
> nonintegarble singularity at x=0 and
> would have returned at second stage a negative value for a possitive
> integrand in the integration
> range.
>
> A lot of evolution has taken place. Don't you agree?
>
>
> Kind Regards
> Dimitris
>
>
>
> =CF/=C7 Michael Weyrauch =DD=E3=F1=E1=F8=E5:
> > Hello,
> >
> >   Dimitris, this is a marvelous solution to my problem. I really apprec=
ia=
> te
> > your help. I will now see if I can solve all my other (similar) integra=
ls=
>  using the same trick.
> > Timing is not really the big issue if I get results in a reasonable amo=
un=
> t of time.
> >
> > Also the references you cited are quite interesting, because they give =
so=
> me insight
> > what might go on inside Mathematica concerning integration.
> >
> > I also agree with you that it is my task as a programmer to "help" Math=
em=
> atica
> > and guide it into the direction I want it to go. Sometimes this is an "=
ar=
> t"...
> >
> > Nevertheless, in the present situation I do not really understand why M=
at=
> hematica wants
> > me to do that rather trivial variable transformation, which is at the h=
ea=
> rt of your solution.
> > The integrand is still a rather complicated rational function of the sa=
me=
>  order. The form
> > of the integrand did not really change
> > substantially as it is the case with some other ingenious substitutions=
 o=
> ne uses in order to
> > do some complicated looking integrals "by hand".
> >
> > I think the fact that we are forced to such tricks shows that the Mathe=
ma=
> tica integrator
> > is still a bit "immature" in special cases, as also the very interestin=
g =
> article by D. Lichtblau,
> > which you cite, seems to indicate. So all this is probably perfectly kn=
ow=
> n to the
> > Mathematica devellopers. And I hope the next Mathematica version has al=
l =
> this "ironed out"??
> >
> > Many thanks again,  Michael



  • Prev by Date: Re: Re: Picking Arguments
  • Next by Date: Possible bug in NSolve[equation, variable, precission]
  • Previous by thread: Re: How to choose real positive solutions?
  • Next by thread: Possible bug in NSolve[equation, variable, precission]