# Integration using assumption in Mathematica

I want to reproduce the solution of the following integral, using Mathematica: $$\int_0^1duu(1-u)^2\frac{1}{(1-u)(1-v)}\left(\frac{1-u}{u}(1+\frac{1}{1-v})\theta(u-v)+\frac{1-v}{v}(1+\frac{1}{1-u})\theta(v-u)\right)\left(2u-1\right)^n$$ Basically this is a diagonalization of a kernel function in the interval $(0,1)$ with respect to the polynom $(2v-1)^n$ and weight $u(1-u)^2$. The variables $u$ and $v$ have to be in the $(0,1)$ interval. I know that the solution is this expression: $\frac{1}{2(n+1)(n+2)(n+3)}\sum_{m=0}^n \left((5+2n)(-1)^{n-m}+3+2m \right)\left( 2v-1\right)^m$.

I am writing this code in Mathematica, where I have split the integral into two parts because of the theta-function.

    I1 = Integrate[u*(1 - u)^2*(((1 - u)/u)*(1 + 1/(1 - v)))*
((2*u - 1)^n/((1 - u)*(1 - v))), {u, v, 1},
Assumptions -> {n \[Element] Integers && n>0 && 0 < u < 1 && 0 < v < 1}];
I2 = Integrate[u*(1 - u)^2*((1 - v)/v)*(1 + 1/(1 - u))*((2*u -  1)^n/((1 - u)*(1 - v))),
{u, 0, v}, Assumptions -> {n \[Element] Integers && n>0 && 0 < u < 1 && 0 < v < 1}];


but I am not getting the right solution. I tried to subtract the solution I get from the analytic one and I do not get zero. Am I doing something wrong in the "Assumptions"-part in the code? The n is Natural number. I would deeply appreciate any help or insight.

• Welcome to Mma.SE. Start by taking the tour now and learning about asking and what's on-topic. Always edit if improvable, show due diligence, give brief context, include minimal working example of your code and data in formatted form. By doing all this you help us to help you and likely you will inspire great answers. The site depends on participation, as you receive give back: vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. – rhermans Aug 21 '18 at 16:38

I1 = Integrate[
u*(1 - u)^2*(((1 - u)/u)*(1 + 1/(1 - v)))*((2*u - 1)^
n/((1 - u)*(1 - v))), {u, v, 1},
Assumptions -> {n \[Element] Integers && n > 0 && 0 < u < 1 && 0 < v < 1}];

I2 = Integrate[u*(1 - u)^2*((1 - v)/v)*(1 +
1/(1 - u))*((2*u - 1)^n/((1 - u)*(1 - v))), {u, 0, v},
Assumptions -> {n \[Element] Integers && n > 0 && 0 < u < 1 && 0 < v < 1}];

ans1 = FullSimplify[I1 + I2][]


$\frac{5 (-1)^n v^2+(4 v-5) (2 v-1)^{n+2}-10 (-1)^n v+2 n (v-1) \left((2 v-1)^{n+2}+(-1)^n (v-1)\right)+5 (-1)^n-v^2+2 v}{4 (n+1) (n+2) (n+3) (v-1)^2 v}$

In the above I used [] after FullSimplify[I1 + I2] to extract the answer from the conditional expression.

While Integrate will sometimes give answers that include special functions that represent series (e.g., the polylogarithm function), it favors closed-form solutions, as seen above. Thus, to check equivalence, we need to convert your solution to closed form:

ans2 = 1/(2 (n + 1) (n + 2) (n + 3)) Sum[((5 + 2 n) (-1)^(n - m) + 3 + 2 m)*(2 v - 1)^m, {m, 0, n}] // FullSimplify


$\frac{5 (-1)^n v^2+(4 v-5) (2 v-1)^{n+2}-10 (-1)^n v+2 n (v-1) \left((2 v-1)^{n+2}+(-1)^n (v-1)\right)+5 (-1)^n-v^2+2 v}{4 (n+1) (n+2) (n+3) (v-1)^2 v}$

ans1===ans2


$True$

Using Boole you can integrate in one step and get the analytic result without warnings:

lsg = Integrate[(
u*(1 - u)^2)/((1 - u)*(1 -v))*(((1 - u)/u) (1 + 1/(1 - v)) Boole[u >= v] + ((1 - v)/v) (1 + 1/(1 - u)) Boole[u < v])*(2*u - 1)^n, {u, 0, 1}
, Assumptions -> {n \[Element] Integers && n > 0, 0 < v < 1}] //FullSimplify
(*(5 (-1)^n + 2 v - 10 (-1)^n v - v^2 + 5 (-1)^n v^2 + (-1 + 2 v)^(2 + n) (-5 + 4 v) +2 n (-1 + v) ((-1)^n (-1 + v) + (-1 + 2 v)^(2 + n)))/(4 (1 +n) (2 + n) (3 + n) (-1 + v)^2 v)*)


Collect[lsg /. v -> (vn + 1)/2, vn^k_] /. vn -> 2 v - 1