# Integrate $x^{-d/2}(1-x)^{(d-3)/2}$

I am trying to find the result of $$\int x^{-d/2}(1-x)^{(d-3)/2}dx$$ where $$0 and $$d\ge2$$ is an integer.

Mathematica gives the following:

Clear[d];
Integrate[x^(-d/2) (1 - x)^((d - 3)/2), x, Assumptions -> 0 < x < 1]

-((2 x^(1 - d/2)Hypergeometric2F1[(3 - d)/2, 1 - d/2, 2 - d/2, x])/(-2 + d))


This seems to be fine except for even values of $$d\ge4$$ because in this case the hypergeometric series is not defined. I've also tried the following:

Clear[d];
d = 2 k;
$Assumptions = k > 0 && k \[Element] Integers; Integrate[x^(-d/2) (1 - x)^((d - 3)/2), x, Assumptions -> 0 < x < 1]  but Mathematica still gives the same expression: (x^(1 - k) Hypergeometric2F1[1 - k, 3/2 - k, 2 - k, x])/(1 - k)  If I try to evaluate this expression for any integer value of $$k\ge1$$ it gives ComplexInfinity  as expected. However, the integral clearly exists as if I tell Mathematica to integrate $$\int x^{-d/2}(1-x)^{(d-3)/2}dx$$ for a specific value of $$d$$ it always gives an answer; for example, for $$d=4$$: d = 4; Integrate[x^(-d/2) (1 - x)^((d - 3)/2), x, Assumptions -> 0 < x < 1]  -(Sqrt[1 - x]/x) + ArcTanh[Sqrt[1 - x]]  I need an expression for general $$d$$, however. Any idea how I can get Mathematica to do this integral in general? • Welcome to Mathematica StackExchange! I am slightly confused. You are integrating over$x$, yet you are putting the$x$range to assumptions. Clearly you want a definite integral,$\int_0^1 x^{-d/2}(1-x)^{(d-3)/2}\, \mathrm{d}x$, right? Then you should use Integrate[(1 - x)^(1/2 (-3 + d)) x^(-d/2), {x, 0, 1}]. This gives$\Gamma \left(1-d/2\right) \Gamma \left((d-1)/2\right)/\sqrt{\pi }$for$1< d < 2$. Commented May 26, 2023 at 13:10 • No, I do not want a definite integral, I want the indefinite integral. In the context in which I am trying to solve this integral my$x$is between$0$and$1$, but I don't need the definite integral. Commented May 26, 2023 at 13:18 • You can do a math trick: shift your$d$by$3$and integrate$\int x^{-(d+3)/2}(1-x)^{d/2}dx\$. Commented May 26, 2023 at 14:17
• You say you don't need the definite integral, but beware. Commented May 26, 2023 at 16:37
• @user58955 Thanks! This is interesting, and I'm curious, why does this trick work? Commented May 29, 2023 at 12:03

## 2 Answers

This is an incomplete Euler beta function: Beta[z0, z1, a, b] is

$$B_{z_0,z_1}(a,b)=\int_{z_0}^{z_1}t^{a-1}(1-t)^{b-1}dt.$$

Define

f[d_, x_] = Beta[1, x, 1 - d/2, (d - 1)/2];


and check that its $$x$$-derivative matches your expression:

D[f[d, x], x] // FullSimplify
(*    (1 - x)^(1/2 (-3 + d)) x^(-d/2)    *)


where I've quite arbitrarily picked $$z_0=1$$; any value $$z_0\in(0,1]$$ will work (but not $$z_0=0$$!); even some complex values would work, as in the hypergeometric solutions coming from user58955's comment.

Plot some values:

Plot[Evaluate@Table[f[d, x], {d, 1, 10}], {x, 0, 1}]


An extension of @user58955's trick:

ans = Integrate[
int = x^(-d/2) (1 - x)^((d - 3)/2) /. d -> d + 3, {x, 1/4, x},
Assumptions -> 0 < x < 1] /. d -> d - 3 // Normal
(*
4 I^(3 - d) Hypergeometric2F1[1/2, (3 - d)/2, 3/2, 4] -
(2 I^(3 - d) Hypergeometric2F1[1/2, (3 - d)/2, 3/2, 1/x])/Sqrt[x]
*)

psol = ParametricNDSolveValue[{y'[x] == int /. d -> d - 3,
y[1/4] == 0}, y, {x, 0, 1}, {d}]

Clear[d];
Manipulate[
Quiet[
Plot[{ans, psol[d][x]} /. d -> d0 // Evaluate, {x, 0, 1},
PlotStyle -> {AbsoluteThickness[6], AbsoluteThickness[3]}],
ParametricNDSolveValue::ndsz],
{d0, 4, 10, 1, Appearance -> "Labeled"}
]

• As a warning to others, in 12.3 or 13.0, a different (wrong?) result is obtained. Commented May 26, 2023 at 19:59
• @Domen Just to be clear, the error comes from the Integrate[] result for even values of d. Apparently Integrate[] changes its behavior now and then. :) Commented May 26, 2023 at 20:33