Re: a question about the UnitStep function

*To*: mathgroup at smc.vnet.net*Subject*: [mg58447] Re: a question about the UnitStep function*From*: Maxim <ab_def at prontomail.com>*Date*: Sat, 2 Jul 2005 04:07:10 -0400 (EDT)*References*: <da2msl$944$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

On Fri, 1 Jul 2005 06:12:37 +0000 (UTC), Zhou Jiang <jiangzhou_yz at yahoo.com> wrote: > > Dear Mathgroup, > I want to let Mathematica compute the convolution of two sqare waves. I > did as follows > f[x_]:=(UnitStep[x+1]-UnitStep[x-1])/2; > integrand=f[z] f[x-z]; > Assuming[Element[x, Reals], Integrate[integrand, {z, -Infinity, > Infinity}]] > Mathematica gave me the result as follows, > ((-1 + x) UnitStep[-1 + x] - x UnitStep[x] + (2 + x) UnitStep[2 + x])/4 > I plot the result to check > Plot[%,{x,-10,10}, PlotRange->All]; > It is clear wrong since the convolution of two square waves should be > convergent. Can anyone give me some help with the subtlties about the > UnitStep function? Any thoughts are appriciable. > Use PiecewiseIntegrate ( http://library.wolfram.com/infocenter/MathSource/5117/ ): In[52]:= PiecewiseIntegrate[f[z]*f[x - z], {z, -Infinity, Infinity}] Out[52]= If[-2 < x < 0, (2 + x)/4, 0] + If[Inequality[0, LessEqual, x, Less, 2], (2 - x)/4, 0] Also you can obtain the correct result from Integrate if you break the domain of the parameter values into several 'simpler' cases: In[53]:= L = Assuming[#, Integrate[f[z]*f[x - z], {z, -Infinity, Infinity}]]&; Piecewise[{L[#], #}& /@ {x < -1, x == -1, -1 < x < 1, x == 1, 1 < x}] // PiecewiseExpand Out[54]= Piecewise[{{1/4, x == -1 || x == 1}, {1/2, x == 0}, {(2 - x)/4, 0 < x < 1 || Inequality[1, Less, x, LessEqual, 2]}, {(2 + x)/4, Inequality[-2, LessEqual, x, Less, -1] || -1 < x < 0}}] But this isn't very reliable, for example, changing -1 < x < 1 to -1 < x <= 1 would give a wrong answer. Maxim Rytin m.r at inbox.ru