Re: piecewise integration

*To*: mathgroup at smc.vnet.net*Subject*: [mg66998] Re: piecewise integration*From*: "David W.Cantrell" <DWCantrell at sigmaxi.org>*Date*: Tue, 6 Jun 2006 06:28:37 -0400 (EDT)*References*: <200606040601.CAA14529@smc.vnet.net> <e60op0$ga8$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: > On 4 Jun 2006, at 15:01, Chris Chiasson wrote: > > > The Integrate result seems pretty weak. Is there any way to obtain a > > more explicit exact answer besides manually converting the Piecewise > > function to two UnitStep functions? Can the same be done if the final > > limit of integration is a variable? > > > > in > > > > load[x_]=-9*10^3*DiracDelta[x]+Piecewise[{{x*10*(10^3/3), > > 0<=x<=3}}]-6*10^3*DiracDelta[x-5]//InputForm > > > > out > > > > -6000*DiracDelta[-5 + x] - 9000*DiracDelta[x] + > > Piecewise[{{(10000*x)/3, 0 <= x <= 3}}, 0] > > > > in > > > > Integrate[load[x],{x,0,5}]//InputForm > > > > out > > > > Integrate[InputForm[-6000*DiracDelta[-5 + x] - 9000*DiracDelta[x] + > > Piecewise[{{(10000*x)/3, 0 <= x <= 3}}, 0]], {x, 0, 5}] > > > > -- > > http://chris.chiasson.name/ > > > > I am sure Maxim does not need my help to advertise his package but > somehow people still keep posting such questions with surprising > frequency. It shouldn't surprise you. Such questions will continue to be posted frequently until Mathematica _itself_ can adequately handle integration of Piecewise functions. > Even if for some reason you do not want to use a third > party package you can always look at the Mathematica code inside, > which should answer questions such as these. > > load[x_] = -9*10^3* > DiracDelta[x] + Piecewise[{{x*10*(10^3/3), 0 <= > x <= 3}}] - 6*10^3*DiracDelta[x - 5]; > << piecewise` > > In[3]:= > PiecewiseIntegrate[load[x],{x,0,5}] > > Out[3]= > 0 That might or might not be what Chris wanted. It depends on whether he wanted integration of DiracDelta to be handled as Mathematica does or as PiecewiseIntegrate does. Using Mathematica, we have, for example, In[28]:= Integrate[DiracDelta[x],{x,0,2}] Out[28]= 1/2 rather than 1, which I infer is what PiecewiseIntegrate would do. If Chris really wanted the integration of the DiracDelta functions to be handled as Mathematica does, then I should think he'd want Integrate[load[x],{x,0,5}] to return 7500, rather than your Out[3]=0. David > In[4]:= > PiecewiseIntegrate[load[x], {x, 0, a}] > > Out[4]= > If[Inequality[0, Less, a, LessEqual, 3], (5000*a^2)/3, 0] + If[3 < a, > 15000, 0] + If[a < 0, 9000, 0] + If[0 <= a, -9000, 0] + > If[5 <= a, -6000, 0] > > Andrzej Kozlowski

**References**:**piecewise integration***From:*"Chris Chiasson" <chris@chiasson.name>