I try to evaluate an Integral of a Heaviside function, but it turns out with an erroneous output(zero). Here is my integral:

Integrate[HeavisideTheta[k - Sqrt[kx^2 + ky^2 + kz^2]], 
          {kx, -Infinity, Infinity}, 
          {ky, -Infinity, Infinity}, 
          {kz, -Infinity, Infinity}, {kx, ky, kz} ∈ Reals]

The right answer should be a volume of a sphere, but it seems Mathematica doesn't know it.

  • $\begingroup$ Define k first. $\endgroup$
    – Spawn1701D
    May 13, 2013 at 18:21
  • $\begingroup$ How to define k? Can you make it clear? I add Assumptions->k>0 in the integral. It returns 0. $\endgroup$ May 13, 2013 at 19:13

1 Answer 1


You can use :

Integrate[UnitStep[k - Sqrt[kx^2 + ky^2 + kz^2]], 
{kx, -Infinity, Infinity}, {ky, -Infinity, Infinity}, {kz, -Infinity, Infinity}, 
  Assumptions -> {k \[Element] Reals}]
(* -(4/3) k^3 \[Pi] (-1 + UnitStep[-k]) *)

Integrate[Boole[k - Sqrt[kx^2 + ky^2 + kz^2] >= 0],
{kx, -Infinity, Infinity}, {ky, -Infinity, Infinity}, {kz, -Infinity, Infinity}, 
 Assumptions -> {k \[Element] Reals}]
(* Piecewise[{{(4*k^3*Pi)/3, k >= 0}}, 0] *)
  • $\begingroup$ UnitStep doesn't work. It result 0 as same as Heaviside Step. I need to Integrate a lot of HeavisideStep functions, What can I do? $\endgroup$ May 13, 2013 at 19:04
  • $\begingroup$ @luming Why doesn't it work ? I think it's giving the correct result; if you supplement the more stringent assumption k>0 then you get the volume of the sphere as you expect. $\endgroup$ May 13, 2013 at 20:05
  • $\begingroup$ In version 8, both methods work even if I leave out the Assumptions. $\endgroup$
    – Jens
    May 14, 2013 at 3:36
  • $\begingroup$ @Jens I try the code on two differnt computers, both run mathematica7 for students on Windows7. And one of the computers running mathematica8 on linux Fedora16. All of them give the answer 0 when usingUnitStepandHevisideTheta function with or without Assumptions. $\endgroup$ May 14, 2013 at 5:19
  • $\begingroup$ I can confirm that. In version 7 only the 1 dimensional case Integrate[UnitStep[k - Sqrt[kx^2]], {kx, -Infinity, Infinity}] seems to work. $\endgroup$ May 14, 2013 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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