# Mathematica does not help in this integral

I am trying to solve this integral with assumptions:

Assuming[Element[j, Integers] && j >= 0, Integrate[ ρ^(j + 1)*
Cos[θ]^j Sum[Binomial[j, k] (- 1)^(j - k) (2 ρ^2)^k, {k, 0, j}],
{ρ, 0, 1}, {θ, 0, 2 π}]]


I know this integral is different from zero at even values of j. In fact this is expected:

FullSimplify[Assuming[Element[j, Integers] && j >= 0,
Integrate[Cos[θ]^j,{θ, 0, 2 π}]],
Assumptions -> Mod[j, 2] == 0]


However, the following returns zero for even and odd values of j, and it is puzzling me:

Assuming[Element[j, Integers] && j > 0 && Mod[j, 2] == 0,
Integrate[ ρ^(j + 1) Sum[Binomial[j, k] (- 1)^(j - k) (2 ρ^2)^k,
{k, 0, j}], {ρ, 0, 1}]]


I do not know what I am ignoring or doing wrong.

Any help will be welcome.

• I get this: !Mathematica graphics mathematica 10.0.2 Apr 8, 2015 at 8:26
• So, zero for even an odd values for 'j'. However, it cannot be as providing values for j from zero to, namely, 10, the integral gives a nonzero value for even 'j'. Apr 8, 2015 at 8:32
• @JoséAntonioDíazNavas You are not doing anything wrong. It is just a bug in Integrate. Apr 8, 2015 at 12:20
• (1) This may be more to your liking. Integrate[\[Rho]^(j + 1) Sum[ Binomial[j, k] (-1)^(j - k) (2 \[Rho]^2)^k, {k, 0, j}, Assumptions -> Element[j, Integers] && j > 0], {\[Rho], 0, 1}, Assumptions -> Element[j, Reals] && j > 0] Apr 8, 2015 at 15:52
• +1 because it led me to an interesting study, cf. my answer Apr 11, 2015 at 22:38

Although Daniel pointed correctly out that problems related to Integrate have been the subject of many discussion here, I found it worthwhile to study this case in detail, because a condition including Mod was not discussed up to now, as far as I know. The aim is to find out if there is a bug, and if so, where exactly it is sitting, and/or, if possible, to provide rules to avoid the problems.

The difficulty can be traced back in its simplest form to the integral (the integrand is just the sum over binomials) :

$$\int_0^1 \left(2 x^2-1\right)^j \, dx$$

and the problem appears with an assumption of the type Mod[j,2] == 0.

1) Rephrasing the problem with some example cases

For the time being let me just show some of the most elementary cases I have found which show the same "naughty" behaviour.

The "classical" case first:

f1 = Integrate[( -1 + 2  x^2)^j, {x, 0, 1},
Assumptions -> {j > -1, Mod[j, 2] == 0}]

(*
Out= 0
*)


Now replace the factor 2 by a symbol "a"

f2 = Integrate[( -1 + a  x^2)^j, {x, 0, 1},
Assumptions -> {j > -1, Mod[j, 2] == 0}]

(*
Out= 0
*)


The other way round, let the factor be 1, and add the term "a"

f3 = Integrate[( a +   x^2)^j, {x, 0, 1},
Assumptions -> {j > -1, Mod[j, 2] == 0}]

(*
Out= 0
*)


Or let the power be a quantity "b"

f4 = Integrate[( a +   x^b)^j, {x, 0, 1},
Assumptions -> {j > -1, Mod[j, 2] == 0}]

(*
Out= ConditionalExpression[0, Re[b] > 0]
*)

Simplify[%, b > 0]

(*
Out= 0
*)


Letting a -> 1 returns the integral unevaluated

f5 = Integrate[( 1 +   x^b)^j, {x, 0, 1},
Assumptions -> {j > -1, Mod[j, 2] == 0}]

(*
Out= Integrate[(1 + x^b)^j, {x, 0, 1}, Assumptions -> {j > -1, Mod[j, 2] == 0}]
*)


The same results are obtained for any explicit integer number exept zero in place of the 2 in Mod[j,2] == 0.

Now take anything except an explicit non zero integer

f6 =
Integrate[(a +   x^2)^j, {x, 0, 1},
Assumptions -> {j > -1, Mod[j, 1/2] == 0}]

(*
Out= ConditionalExpression[
a^j Hypergeometric2F1[1/2, -j, 3/2, -(1/a)], Re[a] > 0]
*)


Which is different from zero.

The same non zero result appears if we take Sqrt, Pi or an undefined symbol k as the module.

2) Different classes of exact solutions of the integral

First we caculate some exact values of the intergral at explicitly non-negative integer points

t1 = Table[Integrate[(-1 + 2 x^2)^j, {x, 0, 1}], {j, 0, 10}]

(*
Out= {1, -(1/3), 7/15, -(9/35), 107/315, -(151/693), 835/3003, -(1241/
6435), 26291/109395, -(40427/230945), 69299/323323}
*)


and ListPlot them

pt1 = ListPlot[t1,
PlotLabel ->
"The integral t1 = \!$$\*SubsuperscriptBox[\(\[Integral]$$, $$0$$, \
$$1$$]\)(2 \!$$\*SuperscriptBox[\(x$$, \
$$2$$]\)-1\!$$\*SuperscriptBox[\()$$, $$j$$]\)\[DifferentialD]x\nat \
integer points j", PlotStyle -> PointSize[0.02],
PlotRange -> {-0.5, 1.1}, AxesLabel -> {"j", "t1"}]
(* 150412_Plot _pt1.jpg *) Then we calculate the integral without the Mod-condition but with the natural assmption j > -1, appending a neutral Simplify:

g1 = Integrate[(-1 + 2 x^2)^j, {x, 0, 1}, Assumptions -> j > -1] // Simplify

(*
Out= (-Sqrt[\[Pi]] Beta[1/2, -(1/2) - j,
1 + j] + (1 - (-1)^j Cos[j \[Pi]]) Gamma[-(1/2) - j] Gamma[1 + j])/(2 Sqrt[
2 \[Pi]])
*)


The plot of this complex function versus j looks like

pg1 = Plot[{Re[g1], Im[g1]}, {j, 0, 4},
PlotLabel -> "Plot g1\nblue curve = Re\nred cureve = Im"]
(* 150410_Plot _pg1.jpg *) At the integer points it concides with tg1:

tg1 = Table[g1, {j, 1, 10}] // FullSimplify

(*
Out= {-(1/3), 7/15, -(9/35), 107/315, -(151/693), 835/3003, -(1241/
6435), 26291/109395, -(40427/230945), 69299/323323}
*)


Now we apply the Mod condition alone

g2c = Integrate[(-1 + 2 x^2)^j, {x, 0, 1}, Assumptions -> Mod[j, 2] == 0]

(*
Out= ConditionalExpression[-(Beta[1/2, -(1/2) - j, 1 + j]/(2 Sqrt)), j > -1]
*)


and execute Simplify afterwards (if done jointly, the notorious 0 reaults).

g2 = Simplify[g2c, j > -1]

(*
Out= -(Beta[1/2, -(1/2) - j, 1 + j]/(2 Sqrt))
*)


The plots gives us a surprise

Plot[g2, {j, 0, 4}, PlotLabel -> "Plot g2 (real function) versus"]
(* 150410_Plot _pg2.jpg *) Applying the Mod condition directly to the integand gives us still another function:

g3 =
Integrate[Simplify[(-1 + 2 x^2)^j, Mod[j, 2] == 0], {x, 0, 1},
Assumptions -> {j > -1}]

(*
Out= ((-1)^j Gamma[-(1/2) - j] Gamma[1 + j])/(2 Sqrt[2 \[Pi]]) + (
Sqrt[\[Pi]/2] Gamma[1 + j])/(
2 Gamma[3/2 + j]) + ((-2)^
j Hypergeometric2F1[-(1/2) - j, -j, 1/2 - j, 1/2])/(1 + 2 j)
*)

pg3 = Plot[{Re[g3], Im[g3]}, {j, 0, 4},
PlotLabel -> "Plot g3\nblue curve = Re\nred cureve = Im"]
(* 150410_Plot _pg3.jpg *) In this case the values at the integer point do not conincide with t1

t3 = Table[g3, {j, 1, 10}]

(* Out= {1/3, 7/15, 9/35, 107/315, 151/693, 835/3003, 1241/6435, 26291/109395, 40427/230945, 69299/323323}
*)


But g3 gives the absolute values.

3) Discussion

In view of the multitude of strange results obtained here it is not easy to draw valid general conclusions.

I would state, however, first of all that we have a buggy behaviour here because Mathematica returns false results instead of refusing the caculation at all or at least give warnings.

Sufficient ingredients to produce the observed buggy behaviour are:

(i) two branch points (like at x=-1 and x=+1 in the current case) and an integration path on the branch cut and going beyond one of the branch points

(ii) the combined conditions j>-1 and Mod[j,2]==0

The two conditions in question are complementary in the sense that they lead - when continued to the real j-axis - to different classes of functions as follows

a) j>-1 (bounded oscillatory, g1)

b) Mod[j,2,]==0, or any non-zero integer instead of 2 (poles, g2)

If we request both conditions to hold together the result is zero. This Looks as if Mathematica cannot decide which class is to be chosen, and therefore gives zero.

I would appreciate a discussion with other users interested in this topic.

• Very nice explanation. It is very interesting that Mathematica finds the correct result with a variable change x=2\[Rho]^2-1. Thus, Integrate[ ((x + 1)/2)^(j/2) x^j/4, {x, -1, 1}, Assumptions -> Element[j, Integers] && j >= 0] gives 2^(-2 - j/2) Gamma[1 + j] (((-1)^j Gamma[1 + j/2])/Gamma[2 + (3 j)/2] + Hypergeometric2F1Regularized[-(j/2), 1 + j, 2 + j, -1]), which solves my problem. Apr 15, 2015 at 10:33