Re: difference between HeavisidePi and UnitBox

*To*: mathgroup at smc.vnet.net*Subject*: [mg100488] Re: difference between HeavisidePi and UnitBox*From*: John Doty <jpd at whispertel.LoseTheH.net>*Date*: Fri, 5 Jun 2009 03:04:17 -0400 (EDT)*References*: <gvq08j$moo$1@smc.vnet.net> <gvtmcu$gc6$1@smc.vnet.net> <200906021041.GAA08533@smc.vnet.net> <h050lh$ack$1@smc.vnet.net>

Andrzej, I agree with what you say here, but as a user of this functionality let me amplify a bit. Andrzej Kozlowski wrote: > It depends on your purpose. For some simple purposes they are > equivalent but there is a huge difference when you try to do calculus > with them. The basic issue is that "function", "derivative", and "integral" mean different things in different mathematical contexts. For the benefit of those who haven't encountered this, start at page 255 of: http://books.google.com/books?id=lMdz84dWNnAC&pg=PA262&lpg=PA262&dq=davis+hersh+fourier&source=bl&ots=Bq4ZMnH4w_&sig=kzqcZZnwUT3gFovNNRHRgC3m2j4&hl=en&ei=LdsmSv29PILyMsKt8PoC&sa=X&oi=book_result&ct=result&resnum=1#PPA255,M1 for a fine overview of these issues. > You can perform most natural operations such as > differentiation or integration on generalized functions: > > D[HeavisidePi[x], x] > 2*DiracDelta[2*x + 1] - 2*DiracDelta[2*x - 1] > > which is a well behaved generalized function while > > D[UnitBox[x], x] > > Piecewise[{{Indeterminate, x == 1/2 || x == -(1/2)}}, 0] > > is the zero function with two undefined values at 1/2 and -1/2, > basically a useless object. UnitBox has the unfortunate property that it doesn't have derivatives at the important points. On the other side, HeavisideTheta isn't numeric at those points, so it would be troublesome in numerical analysis. Which one you should choose depends on what you're going to do with them. Now, this isn't really much of a problem when using the math to solve an scientific or engineering problem by hand: the physical nature of the problem determines the interpretation of the mathematical symbols. Most scientists and engineers aren't even aware of the issues here, and those of us who are rarely worry about them when scribbling on the back of the envelope. But Mathematica only sees the symbols, not the reality (if any) behind them. > So, for example: > > Integrate[D[HeavisidePi[x], x], {x, -Infinity, 0}] > 1 > > while naturally > > Integrate[D[UnitBox[x], x], {x, -Infinity, 0}] > 0 > > I came up with these examples just off hand so they may look a bit > artificial but it is easy to find ones that arise in serious problems. Not so artificial when you realize that Mathematica is likely to evaluate such expressions as it breaks down more realistic problems. I suspect this is exactly the kind of thing behind the difficulties Mathematica used to have when given calculations that required generalized functions: http://forums.wolfram.com/mathgroup/archive/2000/Apr/msg00043.html In the early days, Wolfram apparently believed that these issues could be finessed by heuristics similar to the way we do applied math by hand. So, the only explicit generalized function was DiracDelta, and UnitStep's treatment depended on the undocumented heuristics. That didn't work very well. In recent versions, since the introduction of the distinction between the Heaviside generalized functions and their numerical counterparts, Mathematica's behavior in this area has been much better. For me, the main application here is in analyzing "noises", such as "white" and "flicker" noise: http://www.nr.com/whp/Flicker_Noise_1978.pdf For some purposes here, it's very handy to do symbolic calculations using generalized functions, rather than numerical simulations. > > Andrzej Kozlowski > > On 2 Jun 2009, at 19:41, Anatoly wrote: > >> I understand that it doesn't matter. There's even some discussion >> here about it http://mathworld.wolfram.com/RectangleFunction.html >> >> My question is regarding "The piecewise version of the rectangle >> function is implemented in Mathematica as UnitBox[x], while the >> generalized function version is implemented as HeavisidePi[x]." >> >> why do we need both? I find the integral transforms (I use mostly >> FourierTransform) actually work much better with the piecewise UnitBox >> for 5-bar patterns that I like to use. >> >> Does anyone have a thorough explanation of when generalized functions >> are better than piecewise and vice versa? > ... -- John Doty, Noqsi Aerospace, Ltd. http://www.noqsi.com/ -- The axiomatic method of mathematics is one of the great achievements of our culture. However, it is only a method. Whereas the facts of mathematics once discovered will never change, the method by which these facts are verified has changed many times in the past, and it would be foolhardy to expect that changes will not occur again at some future date. - Gian-Carlo Rota

**References**:**Re: difference between HeavisidePi and UnitBox***From:*Anatoly <anatoly.bourov@gmail.com>