MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: a question about the UnitStep function


Peter Pein schrieb:
> Zhou Jiang schrieb:
> 
>>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. 
>> 
>>
> 
> 
> Piecewise works well:
> 
> In[1]:=
> fp[x_] := Piecewise[{{1, -1 <= x <= 1}}, 0];
> cv = Integrate[fp[z]* fp[x - z], {z, -Infinity, Infinity}]
> Out[2]=
> Piecewise[{{2 - x, 0 < x < 2},
>            {2 + x, -2 < x <= 0}}, 0]
Sorry, my eyes have been wide shut (again).
These:

In[1]:=
f1[x_] := Piecewise[{{1/2, -1 <= x <= 1}}, 0];
Timing[Integrate[f1[z]*f1[z - x], {z, -Infinity, Infinity}]]
Out[3]=
{0.328 Second,
  Piecewise[{{(2 - x)/4, 0 < x < 2},
             {(2 + x)/4, -2 < x <= 0]}}]}
In[4]:=
f2[x_] := Boole[-1 <= x <= 1]/2;
Timing[Integrate[f2[z]*f2[z - x], {z, -Infinity, Infinity}]]
Out[5]=
{0.047 Second,
  Piecewise[{{(2 - x)/4, 0 < x < 2},
             {(2 + x)/4, -2 < x <= 0]}}]}

are of course the correct approaches.


-- 
Peter Pein
Berlin
http://people.freenet.de/Peter_Berlin/


  • Prev by Date: How to simulate random samples from crooked coin toss?
  • Next by Date: Re: Can't assign value to symbols
  • Previous by thread: Re: a question about the UnitStep function
  • Next by thread: Re: Periodic function Roots