MathGroup Archive 2000

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

Search the Archive

Re: Integrate with If


> 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
Canada                       www  : http://www.triumf.ca/people/schadow 

========================================================================


  • Prev by Date: Re: shell commands in notebooks
  • Next by Date: Re: Re: A Dead Thread? Re. Coloring ExtendGraphics ListContourPlot s...
  • Previous by thread: Re: Integrate with If
  • Next by thread: Re: Integrate with If