Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The PrincipalValue option of Convolve is used in this question to define the Hilbert transform. However, in Mathematica 9.0.1, the convolution version gives a wrong answer, while the Fourier transform based version still works.

(* Fourier transform version *)
hilbertTransform = Function[{f,u,t}, 
    Module[{fp = FourierParameters -> {1, -1}, x},
        FullSimplify@InverseFourierTransform[-I (2 HeavisideTheta[x] - 1) 
            FourierTransform[f, u, x, fp], x, t, fp]
hilbertTransform[#, v, w] & /@ {Sin[v], Cos[v], 1/(1 + v^2), Sinc[v], DiracDelta[v]}

(* {-Cos[w],Sin[w],w/(1+w^2),(1-Cos[w])/w,1/(π w)} *)

(* Convolve based version which failed for DiracDelta *)    
hilbertTransform2[f_, u_, t_] := 
    FullSimplify[Convolve[f, 1/u, u, t, PrincipalValue -> True]/π]
hilbertTransform2[#, v, w] & /@ {Sin[v], Cos[v], 1/(1 + v^2), Sinc[v], DiracDelta[v]}

(* {-Cos[w],Sin[w],Log[(-1)^(-(1/(1+w^2))) E^(π/(-I+w))]/π,(1-Cos[w])/w,0} *)

Is this a bug?

share|improve this question
Please see the editing help to learn how to format your posts. By indenting code by 4 spaces (or pressing the {} button in the editor), you can highlight them properly. You can view my edit to see how it is done. Secondly, please do not add the bugs tag until it has been decided/confirmed by users here that it is indeed a bug. This blanket restriction is because a lot of people incorrectly use the bugs tag when it is the result of a typo or something similar. – R. M. Jul 25 '13 at 0:16

just different forms:

hilbertTransformV1[f_, u_, t_] :=Module[{fp = FourierParameters -> {1, -1}, x},
   FullSimplify@InverseFourierTransform[-I (2 HeavisideTheta[x] -1) 
      FourierTransform[f, u, x, fp], x, t, fp]];

hilbertTransformV2[f_, u_, t_] := FullSimplify[Convolve[f, 1/u, u, t, 
      PrincipalValue -> True]/Pi]

Looking at the 1/(1 + v^2) test you did, since that shows a difference. But this differece is just a different form of the same expression

v1 = hilbertTransformV1[1/(1 + v^2), v, w]
Out[39]= w/(1 + w^2)

v2 = hilbertTransformV2[1/(1 + v^2), v, w]
Out[40]= Log[E^(Pi/(-I + w))/(-1)^(1/(1 + w^2))]/Pi

Assuming[Element[w, Reals], FullSimplify[ExpToTrig[v2]]]
Out[41]= w/(1 + w^2)

which is the same. Now looking at the last test which showed a difference. DiracDelta handling is always a tricky thing. Changing the PrincipalValue to False produces the same result:

hilbertTransformV2[f_, u_, t_] := 
 FullSimplify[Convolve[f, 1/u, u, t, PrincipalValue -> False]/Pi];

v1 = hilbertTransformV1[DiracDelta[v], v, w]
Out[34]= 1/(Pi*w)

v2 = hilbertTransformV2[DiracDelta[v], v, w]
Out[33]= 1/(Pi*w)

You might ask, why PrincipalValue is set to False for the DiracDelta case? I do not know now without looking more into it. But again DiracDelta always been a special case.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.