# Speeding up Symbolic Integration of Hypercube with Implicit Region

Given:

Clear[\[Gamma], r];
ineq = r + \[Gamma] r > r + \[Gamma] r && r + \[Gamma] (r + r) < r + \[Gamma] (r + r);
reg = ImplicitRegion[ ineq, {{r, 0, 1}, {r, 0, 1}, {r, 0, 1}, {r, 0,
1}, {r, 0, 1}}];
Integrate[1, {r, r, r, r, r} \[Element] reg, Assumptions -> {1 > \[Gamma] > 0}] // AbsoluteTiming I would like to speed up the computation if possible. Current Thoughts:

1.Remove unnecessary conditions: As far as I can tell, all of the piecewise conditions are unnecessary except the one corresponding to True. Using Simplify[] removes some of them, but that function is applied after the fact; not affecting the time.

2.Adding Assumptions: Gamma and r[n] are all Real and between 0 and 1. Adding any combination to Assumptions like:

\$Assumptions = {0 < \[Gamma] < 1, \[Gamma] \[Element] Reals,   r \[Element] Reals, r \[Element] Reals,   r \[Element] Reals, r \[Element] Reals, r \[Element] Reals}


, produces no affect on timing or the output. Another assumption is that I'm integrating over a specific region of a hypercube of n-volume = 1, though I don't know how to include this usefully.

3.Integrating without ImplicitRegion[]: I'm using this function since it allows plugging in any inequality, and it returns the region of the hypercube I'm interested in. There may be a faster way to integrate over a hypercube given an inequality, but I am not aware of it.

• The default value (corresponding to True) is only valid for one value ({\[Gamma] -> (1/2)*(3 - Sqrt)}) in the interval {0, 1}. – Bob Hanlon Oct 14 '19 at 21:25
• How did you determine that? – Logan Smith Oct 14 '19 at 22:08
• See extended comment. – Bob Hanlon Oct 14 '19 at 23:14

This is an extended comment to address the conditions for which the default in the Piecewise applies:

Clear["Global*"];

ineq = r + γ r > r + γ r &&
r + γ (r + r) < r + γ (r + r);

reg = ImplicitRegion[
ineq, {{r, 0, 1}, {r, 0, 1}, {r, 0, 1}, {r, 0, 1}, {r, 0,
1}}];

(int[γ_] = Assuming[1 > γ > 0, Integrate[1,
{r, r, r, r, r} ∈ reg] //
Simplify]) // AbsoluteTiming The three functions are

funcs = {int[γ][[1, 1, 1]], int[γ][[1, 2, 1]],
int[γ][]}

(* {(-1 + 6 γ + γ^2 + 2 γ^4)/(24 γ^2), (
12 - 28 γ + 19 γ^2 - 4 γ^3 + 2 γ^4)/(
24 (-1 + γ)^2), -((-1 + 11 γ - 35 γ^2 + 81 γ^3 -
95 γ^4 + 45 γ^5 - 11 γ^6 + γ^7)/(
24 (-1 + γ) γ^2))} *)


From the conditions specified in the Piecewise, the default value only applies for a single value in the interval {0, 1}

Simplify[ ! 2*γ >= 1 &&
! (Sqrt + 2*γ < 3 ||
(Sqrt + 2*γ > 3 &&
2*γ < 1))]

(* Sqrt + 2 γ == 3 *)

sol = Solve[%, γ][]

(* {γ -> 1/2 (3 - Sqrt)} *)


The first two functions are piecewise continuous at γ == 1/2

Equal @@ funcs[[1 ;; 2]] /. γ -> 1/2

(* True *)


The third (default) function is piecewise continuous with the second function at γ == (3 - Sqrt)/2

Equal @@ funcs[[2 ;; 3]] /. γ -> (3 - Sqrt)/2 // Simplify

(* True *)


Looking at the individual components:

Show[
Plot[funcs[], {γ, 1/2, 1},
PlotStyle -> {{Thick, ColorData}}],
Plot[funcs[], {γ, 0, 1/2},
PlotStyle -> {{Thick, ColorData}}],
Plot[funcs[], {γ, 0, 1},
PlotStyle -> {{Dashed, Lighter@ColorData}}],
PlotRange -> {{0, 1}, {int, int}},
Epilog -> {Red, AbsolutePointSize,
Point[{γ, int[γ]} /. sol]}]
` 