Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: Integrate with piecewise function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44065] Re: Integrate with piecewise function
  • From: "David W. Cantrell" <DWCantrell at sigmaxi.org>
  • Date: Mon, 20 Oct 2003 01:13:33 -0400 (EDT)
  • Organization: NewsReader.Com Subscriber
  • References: <bmt8gd$87u$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"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