Re: (Newbie) More confusion with integral of absolute vals
- To: mathgroup at smc.vnet.net
- Subject: [mg9393] Re: [mg9367] (Newbie) More confusion with integral of absolute vals
- From: David Withoff <withoff>
- Date: Sun, 2 Nov 1997 01:02:23 -0500
- Sender: owner-wri-mathgroup at wolfram.com
> Suppose I want to integrate the absolute value of x over the range a->b. > It's simple enough in Maple V Release 4: > > > ii:=int(abs(x),x=a..b); > > 2 2 > ii := 1/2 b signum(b) - 1/2 a signum(a) > > > assume(0<a,a<b); > > ii; > > 2 2 > 1/2 b~ - 1/2 a~ > > where the tildes (~) indicate there are assumed properties for a and b. > > If I try the same thing in Mathematica 3.01, I get > > In[1]:= ii=Integrate[Abs[x],{x,a,b}] Out[1]= $Aborted > > In other words, Mathematica cannot perform the integral and I must abort > the evaluation. Even if I try to place Assumptions in the Integrate > function, the integration is not performed. What am I missing here? > Can't the integration be performed as easily in Mathematica as it is in > Maple? > > -- > > =========================================== L. Dwynn Lafleur > Professor of Physics > The University of Southwestern Louisiana Lafayette, Louisiana (USA) > lafleur at usl.edu > =========================================== If you replace Abs[x] by Sqrt[x^2] then Mathematica will do the integral: In[1]:= Integrate[Sqrt[x^2], {x, a, b}] 2 2 -(a Sqrt[a ]) b Sqrt[b ] Out[1]= ------------- + ---------- 2 2 or you can add a rule to Integrate that will cause this to be done automatically. The behavior of Integrate[Abs[x],{x,a,b}] in Mathematica Version 3.0 is something that needs to be fixed, and this is one way to fix it. Lurking beneath this seemingly simple integral is some rather awkward trickery, in Maple and essentially everywhere else. For example, the following result from Maple V Release 4 > int(abs(sin(x)), x=a..b); -cos(b) signum(sin(b)) + cos(a) signum(sin(a)) is wrong for all but a narrow range of relationships between the parameters a and b. There are no general algorithms for integrating the absolute value function, so it is likely that there are lots of errors like this. Given all of the work that needs to done I am more than willing to excuse this sort of thing, and am in fact quite impressed that integration algorithms can get the right answer for things like this: In[5]:= Integrate[Abs[Sin[x]], {x, 0, 20}] Out[5]= 13 - Cos[20] I want to stop short of describing integration of absolute value as hopeless, since problems such as these certainly can in principle be fixed, but this is a difficult and largely unsolved problem, and the fact that Maple and Mathematica have various difficulties integrating absolute value is not at all surprising. It is a good idea to check the results for integrals involving functions like absolute value no matter what system you use, and where possible an even better idea is to somehow rearrange the input (such as by using Sqrt[x^2] in place of Abs[x]) so that these problems don't come up in the first place. Dave Withoff Wolfram Research