MathGroup Archive 2003

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

Search the Archive

Re: Integrate with piecewise function


"Chia-Ming" <yucalf at mail.educities.edu.tw> wrote:
> I define a function describing the distance on the edge of a circle.
>
> dis[x_, xi_] := Which[ x - xi >= 0, x - xi, x - xi < 0, xi - x]
>
> Then I find that the command Integrate does not yield the result (37/72).
>
> Integrate[dis[x, 0], {x, 0, 1/6}]

1.  In general, for functions defined piecewise, it's probably best to
rewrite them in terms of UnitStep if you intend to integrate them.
2.  But in your speciific case, you can just use Abs[x - xi] for dis.
3.  I presume you intended the lower limit of integration to be -1,
instead of 0.

> If I use the command NIntegrate, only the numerical result is yielded.
> But I want the exact result.
>
> NIntegrate[dis[x, 0], {x, 0, 1/6}]
> 0.513891
>
> How can I get the exact result, just like I keyin the command by hand.
>
> Integrate[-x, {x, -1, 0}] + Integrate[x-0, {x, 0, 1/6}]
> 37/72

Integrate[Abs[x], {x, -1, 1/6}]

David Cantrell


  • Prev by Date: Re: Integrate with piecewise function
  • Next by Date: Re: Mystery: NIntegrate'ing indeterminate-length integrand!
  • Previous by thread: Re: Integrate with piecewise function
  • Next by thread: Re: Integrate with piecewise function