Re: Integrate with If

• To: mathgroup at smc.vnet.net
• Subject: [mg22203] Re: [mg22180] Integrate with If
• Date: Fri, 18 Feb 2000 02:34:39 -0500 (EST)
• References: <200002170624.BAA04409@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```> Why does
>
>         Integrate[If[Sin[t] > 0, 1, 0] , {t, -Pi, Pi}]
>
> evaluate to 2Pi?
>
>         Plot[If[Sin[t] > 0, 1, 0] , {t, -Pi, Pi} ]
>
> looks all right.
>
>
> Puzzled,
>
> Johan Berglind,
> Chalmers, Goteborg,
> Sweden.
>

I have no an answer, but here are some other 'interesting' results

f[x_] = If[Sin[x] > 0, 1, 0]

Integrate[f[x], {x, -\[Pi], 0}]

gives 0 (correc)

Integrate[f[x], {x, -\[Pi], 2}]

gives 0 (wrong)

\!\(Integrate[f[x], {x, \(-\[Pi]\), \[Pi] - 1\/100000}]\)

gives 0 (wrong).

One way to get a correct result is:

Integrate[f[x], {x, -\[Pi], 0, \[Pi]}]

or with NIntegrate

NIntegrate[f[x], {x, -\[Pi], 0, \[Pi]}]

NIntegrate[f[x], {x, -\[Pi], \[Pi]}]

Wolfgang

========================================================================
Wolfgang Schadow             Phone: +1-604-222-1047 ext. 6453 (office)
TRIUMF                              +1-604-875-6066           (home)
Theory Group                   FAX: +1-604-222-1074
4004 Wesbrook Mall
Vancouver, B.C. V6T 2A3      email: schadow at triumf.ca