# Integrate of Heaviside Function returns an error answer

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.

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

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] *)

• 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? May 13, 2013 at 19:04
• @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. May 13, 2013 at 20:05
• In version 8, both methods work even if I leave out the Assumptions.
– Jens
May 14, 2013 at 3:36
• @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. May 14, 2013 at 5:19
• I can confirm that. In version 7 only the 1 dimensional case Integrate[UnitStep[k - Sqrt[kx^2]], {kx, -Infinity, Infinity}] seems to work. May 14, 2013 at 5:30