Re: Integrate with piecewise function

*To*: mathgroup at smc.vnet.net*Subject*: [mg44076] Re: [mg44052] Integrate with piecewise function*From*: "Peter Pein" <nospam at spam.no>*Date*: Tue, 21 Oct 2003 02:07:50 -0400 (EDT)*References*: <200310190510.BAA08054@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Chia-Ming, NIntegrate[] evaluates the integrand for some numeric values of x. Integrate[] does it's job symbolically. Therefore NIntegrate gets values from dis[], while Integrate[] gets "Which[...]" unevaluated. If you use Abs[x-xi] instead of "dis[]", Integrate[] knows how to handle this function. Integrate[Abs[x],{x,-1,1/6}] gives the desired result. Peter Pein, Berlin petsie at arcAND.de replace && by || to write to me ----- Original Message ----- From: "Chia-Ming" <yucalf at mail.educities.edu.tw> To: mathgroup at smc.vnet.net Subject: [mg44076] [mg44052] Integrate with piecewise function > Excuse me, > > 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}] > > 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 > > Thank you very much for your help! > > > cmyu > >