MathGroup Archive 2000

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

Search the Archive

Re: Integrate with If

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22200] Re: [mg22180] Integrate with If
  • From: Andrzej Kozlowski <andrzej at platon.c.u-tokyo.ac.jp>
  • Date: Fri, 18 Feb 2000 02:34:36 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

on 00.2.17 3:24 PM, Johan Berglind,5879 at johanbe at chl.chalmers.se wrote:

> 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.
> 
This is of course wrong but I would not in general recommend trying this
sort of thing. When you use Integrate Mathematica has to find an
anti-derivative and in this case the antiderivative has a jump at 0.
Integrate is not very good at dealing with singularities. In some cases like
this one you can deal  with this problem  by adding the jump point to the
range of integration as in :
In[15]:=
Integrate[If[Sin[t] > 0, 1, 0] , {t, -Pi, 0, Pi}]

Out[15]=
Pi

Or if you are satisfied with a numerical answer use NIntegrate:

In[16]:=
NIntegrate[If[Sin[t] > 0, 1, 0] , {t, -Pi, Pi}]
Out[16]=
3.14159



  • Prev by Date: Functions with parameters?
  • Next by Date: Re: Animation
  • Previous by thread: Re: Integrate with If
  • Next by thread: Re: Integrate with If