# Definite integral impossible but indefinite possible

I am trying to do a spherical integral in Mathematica:

f[θ_, ϕ_] = (k^4 Cos[θ]^2 Cot[β] Csc[β] Sin[θ]^3 Sin[ϕ]^2)/(
4 (1 + k Cos[θ]) (1 + k Cos[β] Cos[θ] + k Cos[ϕ] Sin[β] Sin[θ])) +
(k^4 Cos[θ] Cos[ϕ] Csc[β] Sin[θ]^4 Sin[ϕ]^2)/(
4 (1 + k Cos[θ]) (1 + k Cos[β] Cos[θ] + k Cos[ϕ] Sin[β] Sin[θ]))


If I try the following:

Integrate[f[θ, ϕ], {ϕ, 0, 2 π}]


Mathematica does not produce an answer. However, if I try to do an analytical integral like this:

g[θ_] = Integrate[f[θ, ϕ], ϕ]


I get an answer very quickly, and that answer differentiates to the integrand I started with. Now I can evaluate the value of the integral I am trying to find by doing:

g[2 π] - g[0]


My question is twofold:

1. Why is this happening in Mathematica? I assume it is because the algorithms for finding a definite and indefinite integrals are different.
2. Is this a valid way of doing the integral in this case (and others)? I am asking because the end result does not agree with a purely numerical integral over the sphere, and this might be the source of error.
• "I assume it is because the algorithms for finding a definite and indefinite integrals are different." - yes, it has to worry about branch cuts and such, since Mathematica assumes everything is complex unless told otherwise. You might wish to look up Assuming[]. Aug 17, 2017 at 14:06
• Thank you @J.M., I know one needs to use assumptions. For the above integral I have tried: Assumptions -> {k > 0 && k < 1 && [Beta] >= 0 && [Beta] <= [Pi] && [Theta] >= 0 && [Theta] <= [Pi] && k [Element] Reals && [Beta] [Element] Reals && [Theta] [Element] Reals} but it hasn't helped much. Aug 17, 2017 at 14:33
• To simplify matters slightly: if you put in a condition like 0 < k <1, then you don't need to put in k ∈ Reals, since your use of the inequality already imposes that condition. Aug 17, 2017 at 14:43

• To quote Robert X Cringly: "Real Soon Now', a computer industry expression meaning In this lifetime, maybe`". :) I cannot give any date certain, but we have had a couple of pre-releases to beta testers, and we're fixing some critical bugs discovered in the process. So hopefully in the fairly near future. Aug 17, 2017 at 23:44