       Re: Bug of Integrate

• To: mathgroup at smc.vnet.net
• Subject: [mg82835] Re: Bug of Integrate
• From: "David W.Cantrell" <DWCantrell at sigmaxi.net>
• Date: Thu, 1 Nov 2007 05:08:26 -0500 (EST)
• References: <fg4dfv\$6c3\$1@smc.vnet.net> <fg6pse\$d44\$1@smc.vnet.net> <fg9pmb\$n1a\$1@smc.vnet.net>

```m.r at inbox.ru wrote:
> On Oct 30, 2:26 am, "David W.Cantrell" <DWCantr... at sigmaxi.net> wrote:
> > Miguel <misv... at gmail.com> wrote:
> > > When I try to calculate the integral
> >
> > > Integrate[Sqrt[1/Cos[t]^2]*3*Cos[t],{t,0,2Pi}]  Mathematica 6.0.1
> > > yields -6*Pi.
> >
> > If so, then that is clearly a bug. But in version 5.2, the result is
> > correct:
> >
> > In:= Integrate[Sqrt[1/Cos[t]^2]*3*Cos[t],{t,0,2Pi}]
> >
> > Out= 0
> >
> > > Simplifying the expresion resultrs Integrate[3,{t,0,2*Pi}] and It is
> > > clear that the correct solution is 6*Pi.
> >
> > No. Simplifying the integrand does not give 3, rather
> >
> > In:= Simplify[Sqrt[1/Cos[t]^2]*3*Cos[t], Element[t,Reals]]
> >
> > Out= 3 Abs[Sec[t]] Cos[t]
> >
> > which BTW is the same as 3 Sign[Cos[t]] for real t except when
> > Cos[t]==0.
> >
> > However, related to the above, version 5.2 does give an incorrect
> > result for a definite integral with a symbolic real limit. Whether this
> > error still exists in version 6, I don't know:
> >
> > In:= Assuming[Element[x,Reals],Integrate[3*Sign[Cos[t]],{t,0,x}]]
> >
> > Out= 3 If[x > 0, x Abs[Cos[x]] Sec[x],
> > Integrate[Sign[Cos[t]], {t, 0, x}, Assumptions -> x <= 0]]
> >
> > The above is incorrect for x > Pi/2. A correct result would have been
> >
> > 3 Sign[Cos[x]] (x - Pi Floor[x/Pi + 1/2])
> >
> > for all real x.
> >
> > David W. Cantrell
>
> Note that your formula isn't correct for x = Pi/2 + Pi k.

Yes. Many thanks for pointing that out! I should have been more careful.

> The correct expression for all real x is
>
> In:= Assuming[0 <= x < 2 Pi, Integrate[3 Sign[Cos[t]], {t, 0,
> x}]] /.
>   x -> Mod[x, 2 Pi]
>
> Out= Piecewise[{{-3 Pi/2, Mod[x, 2 Pi] == 3 Pi/2}, {3 (Pi - Mod[x,
> 2 Pi]), Pi/2 < Mod[x, 2 Pi] < 3 Pi/2}, {-3 (2 Pi - Mod[x, 2 Pi]), 3 Pi/
> 2 < Mod[x, 2 Pi] < 2 Pi}, {3 Mod[x, 2 Pi], 0 < Mod[x, 2 Pi] <= Pi/2}}]

That is _one_ correct expression for all real x. But there are shorter
ones, such as the one which I should have posted originally:

3 ArcSin[Sin[x]]

David W. Cantrell

```

• Prev by Date: Zoom2D
• Next by Date: Re: Frequency response function
• Previous by thread: Re: Bug of Integrate
• Next by thread: Re: Bug of Integrate