# Integrate solution doesn't work when values are substituted

I would like a closed form for $$\text{Integrate}\left[\frac{(1-y)^{\frac{k}{2}+\frac{t}{2}-\frac{1}{2}} (y+1)^{\frac{t}{2}-\frac{k}{2}}}{\sqrt{1-y}-\sqrt{y+1}}-\frac{(1-y)^{\frac{k}{2}+\frac{t}{2}-1} (y+1)^{-\frac{k}{2}+\frac{t}{2}-\frac{1}{2}}}{\sqrt{1-y}-\sqrt{y+1}},\{y,0,1\},\text{Assumptions}\to \{k\in \mathbb{Z},t\in \mathbb{Z}\}\right]$$

Plotting the expression for k = 5, t = 10 say, and we see that this should be well defined. Mathematica gives us the solution $$-\frac{-2^{\frac{t}{2}+1} \Gamma \left(\frac{1}{2} (-k-t+3)\right) \left(\Gamma (t) \left(\pi \left(k^2-4 k+3\right) 2^{\frac{t+1}{2}} (-k+t+2) \csc \left(\frac{1}{2} \pi (k+t)\right) \Gamma \left(\frac{1}{2} (-k+t+2)\right)-2^{k/2} \Gamma (t+1) \left(\sqrt{2} \left(k^2-2 k (t+2)+t^2+4 t+3\right) \, _2F_1\left(\frac{1}{2} (-k-t+2),\frac{1}{2} (-k+t+2);\frac{1}{2} (-k+t+4);\frac{1}{2}\right)-(k-t-2) \left(2 (k-t-3) \, _2F_1\left(\frac{1}{2} (-k-t+3),\frac{1}{2} (-k+t+1);\frac{1}{2} (-k+t+3);\frac{1}{2}\right)+(-k+t+1) \, _2F_1\left(\frac{1}{2} (-k-t+3),\frac{1}{2} (-k+t+3);\frac{1}{2} (-k+t+5);\frac{1}{2}\right)\right)\right) \Gamma \left(-\frac{k}{2}-\frac{t}{2}+1\right)\right)+\pi 2^{\frac{t+1}{2}} \left(2 k^2-k (3 t+8)+t^2+6 t+8\right) \Gamma (t+1) \csc \left(\frac{1}{2} \pi (k+t)\right) \Gamma \left(\frac{1}{2} (-k+t+2)\right)\right)-\pi 2^{t+\frac{1}{2}} \left(k^2-2 k (t+2)+t^2+4 t+3\right) {\sec \left(\frac{1}{2} \pi (k+t)\right)} \Gamma \left(-\frac{k}{2}-\frac{t}{2}+1\right) \left(\left(-k^2+3 k-2\right) \Gamma (t)+(t+1) \Gamma (t+1)\right) \Gamma \left(\frac{1}{2} (-k+t+1)\right)}{4 \sqrt{2} (-k+t+1) (-k+t+2) (-k+t+3) \Gamma (t) \Gamma (t+1) \Gamma \left(\frac{1}{2} (-k-t+3)\right) \Gamma \left(-\frac{k}{2}-\frac{t}{2}+1\right)}$$ assuming $k + t > 0$. If we now try to substitute integer values of $k$ and $t$ into this, it gives an answer of Indeterminate.

How can I persuade Mathematica to give me an expression for the integral that works on integer values (I've tried to use Refine with integer constraints on the result, but that does not change the expression)

• Please share the code in copyable form, so that other users can play with it. No one wants to retype all this code (and double check for correct transition). This will raise your chances for getting quick and competent help. – Mariusz Iwaniuk Jun 30 '18 at 17:09
• Also please show the integer combinations that you tried that didn't work. – JimB Jun 30 '18 at 17:39

History of edits

3.7.18 Simplified derivation of closed form expression in terms of incomplete Beta functions

1.7.18 Complete solution provided

Summary

I have derived an "Integrate[] solution which works fine when values are substituted".

The expression h[k,t] for the integral obtained here is finite in the whole (k,t)-plane except for integer grid points (both k and t are integers) with k+t<=0 where singularities are encountered. These singularities are simple poles (rather than discontinuities as was stated by Bob Hanlon).

On the integers grid the singularities lie on the lines k+t=-n, n=0,1,2,...

Specifically, h[k,t] is finite for all integers k and t with k+t>0.

The behaviour of the integral, especially close to the singularities is illustrated graphically.

Simplified derivation

A compact derivation of a closed expression for the integral goes like this

(1) remove the denominator in the integrand

This is effectively multiplying denominator and numerator with (Sqrt[1 - y] + Sqrt[y + 1]).

f=((1 - y)^(k/2 + t/2 - 1/2) (y + 1)^(t/2 - k/2)/(Sqrt[1 - y] -
Sqrt[y + 1]) - (1 - y)^(k/2 + t/2 -
1) (y + 1)^(-k/2 + t/2 - 1/2)/(Sqrt[1 - y] - Sqrt[y + 1]))


$$f = \frac{(1-y)^{\frac{1}{2} (k+t-1)} \left((y+1)^{\frac{t-k}{2}}-(y+1)^{\frac{1}{2} (-k+t-1)}\right)}{\sqrt{1-y}-\sqrt{y+1}}$$

f1 = FullSimplify[f]

1/2 (1 - y)^(1/2 (-3 + k + t)) (1 + y)^(
1/2 (-1 - k + t)) (-1 + y + Sqrt[1 - y^2])


$$f_{1}=\frac{1}{2} \left(\sqrt{1-y^2}+y-1\right) (1-y)^{\frac{1}{2} (k+t-3)} (y+1)^{\frac{1}{2} (-k+t-1)}$$

(2) Substitute y->1-2x (y=0..1 -> x=0..1/2)

f2 = FullSimplify[2 f1 /. y -> 1 - 2 x, 0 < x < 1/2] // FunctionExpand //
Expand

2^(-1 + t) (1 - x)^(-(k/2) + t/2) x^(-1 + k/2 + t/2) -
2^(-1 + t) (1 - x)^(-(1/2) - k/2 + t/2) x^(-(1/2) + k/2 + t/2)


$$f_{2}=2^{t-1} (1-x)^{\frac{t}{2}-\frac{k}{2}} x^{\frac{k}{2}+\frac{t}{2}-1}-2^{t-1} (1-x)^{-\frac{k}{2}+\frac{t}{2}-\frac{1}{2}} x^{\frac{k}{2}+\frac{t}{2}-\frac{1}{2}}$$

Apart from the factor $2^{t-1}$ each summand has the form $x^{a-1} (1-x)^{b-1}$ which when integrated between 0 and 1/2 gives the (incomplete) Euler Beta-function

Integrate[x^(a - 1) (1 - x)^(b - 1), {x, 0, 1/2}]

ConditionalExpression[Beta[1/2, a, b], Re[a] > 0]


Hence a closed form solution of the integral is

h0[k_, t_] =
2^(-1 + t) ((Beta[1/2, a, b] /. {a -> k/2 + t/2,
b -> 1 - k/2 + t/2}) - (Beta[1/2, a, b] /. {a -> 1 - 1/2 + k/2 + t/2,
b -> 1 - 1/2 - k/2 + t/2}));


$$h_{0}(k,t) = 2^{t-1} \left(B_{\frac{1}{2}}\left(\frac{k}{2}+\frac{t}{2},-\frac{k}{2}+\frac{t}{2}+1\right)-B_{\frac{1}{2}}\left(\frac{k}{2}+\frac{t}{2}+\frac{1}{2},-\frac{k}{2}+\frac{t}{2}+\frac{1}{2}\right)\right)$$

Inserting values gives

h0[5, 10]

512 (-(7/46080) + Beta[1/2, 15/2, 7/2])


numerically

N[%, 20]

0.011734378351166407572


The singularity structure is now easy to see from the fact that $B_{\frac{1}{2}}(a,b)$ has simple poles at negative integer values of the parameter "a" and is holomorph in "b".

Calculations

I do this "with a little help for my friend", Mathematica. The help consists in a simple substitution and a subsequent manual simplification.

$Version "10.1.0 for Microsoft Windows (64-bit) (March 24, 2015)" ClearAll[f, g, h, t, k, y, z]  The integrand in question is f[k_, t_, y_] := ((1 - y)^(k/2 + t/2 - 1/2) (y + 1)^(t/2 - k/2)/(Sqrt[1 - y] - Sqrt[y + 1]) - (1 - y)^(k/2 + t/2 - 1) (y + 1)^(-k/2 + t/2 - 1/2)/(Sqrt[1 - y] - Sqrt[y + 1]))  The numerical value of the integral for parameters k=5, t=10 is iN1 = NIntegrate[f[5, 10, y], {y, 0, 1}, WorkingPrecision -> 20] 0.011734378351166406412  Now our "first aid": the substitution 1-y -> z g[k_, t_, z_] = 1/2 (1 - y)^(1/2 (-3 + k + t)) (1 + y)^( 1/2 (-1 - k + t)) (-1 + y + Sqrt[1 - y^2]) /. y -> 1 - z // Simplify 1/2 (2 - z)^(1/2 (-1 - k + t)) z^(1/2 (-3 + k + t)) (-z + Sqrt[-(-2 + z) z])  Numerical check of the corresponding integral: iN2 = NIntegrate[g[5, 10, z], {z, 0, 1}, WorkingPrecision -> 20] 0.011734378351166406412 iN1 == iN2 True  Now we do the integration without Assumptions[] on k and t which is performed by Mathematica in seconds: i = Integrate[g[k, t, z], {z, 0, 1}] ConditionalExpression[(1/((k + t) (1 + k + t))) 2^(-1 - k) (2 E^( 1/2 (k + t) (-I \[Pi] + Log[2])) (1 + k + t) Hypergeometric2F1[(k - t)/ 2, (k + t)/2, 1/2 (2 + k + t), 1/2] - I E^(1/2 (1 + k + t) (-I \[Pi] + Log[2])) (k + t) Hypergeometric2F1[ 1/2 (1 + k - t), 1/2 (1 + k + t), 1/2 (3 + k + t), 1/2]) (Cos[ 1/2 \[Pi] (k + t)] + I Sin[1/2 \[Pi] (k + t)]), Re[k + t] > 0]  Keeping in mind the condition Re[k+t]>0 (1)  we extract the expression h[k_, t_] = i[[1]];  Remark: the indefinte integral is calculated as well (we skip the expression here for brevity) Evaluation Now we can substitute integer values for k and t respecting condition (1) For the "standard" values of k and t we find h[5, 10] // Simplify % // N 1/90 (-7 + 6 Hypergeometric2F1[-(5/2), 1, 17/2, -1]) 0.0117344  For the smallest integer parameters permitted by (1) we have h[0, 1] // Simplify \[Pi]/4 h[1, 0] // Simplify 1/4 (\[Pi] - Log[4])  Going further up on the (k,t)-integer grid: First on the "borders" Table[h[0, t], {t, 1, 5}] // Simplify {\[Pi]/4, (6 - \[Pi])/8, -(1/6) + \[Pi]/8, 1/96 (44 - 9 \[Pi]), -(1/6) + (3 \[Pi])/32} Table[h[k, 0], {k, 1, 5}] // Simplify {1/4 (\[Pi] - Log[4]), 1/4 (-4 + \[Pi] + Log[4]), 1/4 (2 - \[Pi] + Log[4]), 1/12 (14 - 3 \[Pi] - 6 Log[2]), 1/12 (-5 + 3 \[Pi] - 3 Log[4])}  Then on the diagonal Table[h[n, n], {n, 1, 5}] // Simplify {1/6 (3 - 2 Hypergeometric2F1[1/2, 1, 5/2, -1]), 1/4 - 1/5 Hypergeometric2F1[1/2, 1, 7/2, -1], 1/6 - 1/7 Hypergeometric2F1[1/2, 1, 9/2, -1], 1/8 - 1/9 Hypergeometric2F1[1/2, 1, 11/2, -1], 1/10 - 1/11 Hypergeometric2F1[1/2, 1, 13/2, -1]}  Also there is no problem with real values for k and t Numerical example h[8.5, 3.5] 0.00661082 + 9.56017*10^-17 I  Symbolic example h[\[Pi]/4, E] // Simplify (1/((4 E + \[Pi]) (4 + 4 E + \[Pi])))4 (4 Hypergeometric2F1[1, 1/8 (-4 E + \[Pi]), 1/8 (8 + 4 E + \[Pi]), -1] + 4 E (Hypergeometric2F1[1, 1/8 (-4 E + \[Pi]), 1/8 (8 + 4 E + \[Pi]), -1] - Hypergeometric2F1[1, 1/8 (4 - 4 E + \[Pi]), 1/8 (12 + 4 E + \[Pi]), -1]) + \[Pi] (Hypergeometric2F1[1, 1/8 (-4 E + \[Pi]), 1/8 (8 + 4 E + \[Pi]), -1] - Hypergeometric2F1[1, 1/8 (4 - 4 E + \[Pi]), 1/8 (12 + 4 E + \[Pi]), -1]))  Here's an example with one negative integer k and one non integer t violating the condition k+t>0 which results in a finite value, as it should be: With[{k = -4, t = \[Pi]}, Print[k + t // N]; h[\[Pi], -4] // Simplify] -0.858407 (54 - 36 \[Pi] + 25 \[Pi]^2 + 21 \[Pi]^3 - 8 \[Pi]^4 - 3 \[Pi]^5 + \[Pi]^6)/(2 (-4 + \[Pi]) (-3 + \[Pi]) \[Pi] (-4 + \[Pi]^2) (-3 - \ \[Pi] + 3 \[Pi]^2 + \[Pi]^3))  Singularity structure The overall behaviour of h in the real (k,t)-plane is shown in this 3D graph We identify lines of singularity given by k+t=-n, n = 0,1,2,...  The next graph shows h[k,t] along the line t=k, i.e. perpendicular to the lines of singularity The cross section shows that h[k,k] has poles at k = -(2m+1), m=0, 1, 2, ... The next two graphs follow the pole lines k+t==-n+[Epsilon] in an [Epsilon]-vicinity for n=0 and n=4 respectively: We have plotted h*[Epsilon] which is almost independent of [Epsilon]. This shows that h diverges like 1/[Epsilon] for [Epsilon]->0. Note added on 2.7. In oder to study the singularities in more detail it is convenient to take k+t=m as the parameter besides k: hm[k_,m_] = h[k, t] /. t -> m - k // Simplify (1/(m (1 + m)))2^(-1 - k + m/ 2) (2 (1 + m) Hypergeometric2F1[k - m/2, m/2, 1 + m/2, 1/2] - Sqrt[2] m Hypergeometric2F1[1/2 + k - m/2, (1 + m)/2, (3 + m)/2, 1/2])  This also simplifies the expression further. For given k this function has simple poles in m for negative integers. This can be derived from the hypergeometric functions. But we prefer to illustrate it graphically (k can be any real number, even integers; we make two specific choices) Positive k: With[{k = 5}, Plot[hm[k,m], {m, -15, 2}, PlotRange -> {-5, 5}]] Negative k: With[{k = -5}, Plot[hm[k,m], {m, -15, 2}, PlotRange -> {-1, 1}]] In the case of k<0 the |k| poles from -|k|-1 to -2|k| vanish. $Version

(* "11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)" *)

Clear[f]

f[k_, t_] = Assuming[Element[{k, t}, Integers] && k + t > 0,
Integrate[(1 - y)^(k/2 + t/2 - 1/2) (y + 1)^(t/2 - k/2)/(Sqrt[1 - y] -
Sqrt[y + 1]) - (1 - y)^(k/2 + t/2 -
1) (y + 1)^(-k/2 + t/2 - 1/2)/(Sqrt[1 - y] - Sqrt[y + 1]), {y, 0, 1}]]

(* -((2^(-1 + t) Gamma[1/2 (1 - k + t)] Gamma[1/2 (-1 + k + t)])/Gamma[t]) + (
2^(-1 + t) Gamma[1/2 (3 - k + t)] Gamma[1/2 (-1 + k + t)])/Gamma[1 + t] + (
2^(-1 + t) Gamma[1/2 (2 - k + t)] Gamma[(k + t)/2])/
Gamma[1 + t] + (2^(
1/2 (-4 + k +
t)) (2 (3 + k^2 + 4 t + t^2 - 2 k (2 + t)) Hypergeometric2F1[
1/2 (2 - k - t), 1/2 (2 - k + t), 1/2 (4 - k + t), 1/2] -
Sqrt[2] (-2 + k -
t) (2 (-3 + k - t) Hypergeometric2F1[1/2 (3 - k - t),
1/2 (1 - k + t), 1/2 (3 - k + t), 1/
2] + (1 - k + t) Hypergeometric2F1[1/2 (3 - k - t),
1/2 (3 - k + t), 1/2 (5 - k + t), 1/2])))/((-3 + k - t) (-2 + k -
t) (-1 + k - t)) *)


Plotting the function shows that it is discontinuous along stripes (t - k == n, Element[n, Integers] && n < 0

Plot3D[f[k, t], {k, 0, 10}, {t, 0, 10},
AxesLabel -> (Style[#, 14, Bold] & /@ {"k", "t"}), MaxRecursion -> 3,
PlotPoints -> 50, ClippingStyle -> None, Mesh -> {9, 9}]


f[5, 10]

(* -(64/45) + (143 \[Pi])/512 -
2/21 Sqrt[2] (-(847/(60 Sqrt[2])) + (11 (2048 + 819 \[Pi]))/(6144 Sqrt[2])) *)

% // N

(* 0.0117344 *)

f[8.5, 3.5] // Quiet

(* Indeterminate *)

max = 8;
(Table[f[k, t], {k, 0, max}, {t, 0, max - 1}] // N) /. {ComplexInfinity ->
"*", Indeterminate -> "--"} //
TableForm[#, TableHeadings -> {Range[0, max], Range[0, max]}] & // Quiet


You may be able to evaluate at the discontinuities by taking the limit

Limit[f[5, t] // Simplify, t -> 3] // N

(* 0.0170566 *)

• @ Bob Hanlon The might be an error in your expression for the integral. My expression gives a finite value for f[8.5, 3.5]. – Dr. Wolfgang Hintze Jul 2 '18 at 3:36
• @Dr.WolfgangHintze - The different versions of Mathematica (10.1 and 11.3) provide different forms of the original integral that are essentially the same (Equal) but have different discontinuities. – Bob Hanlon Jul 2 '18 at 4:31
• @ Bob Hanlon So I would say that version 11.3 has a problem. Mathematically speaking there are no discontinuities in the integral, rather the singularities are simple poles in the variable m=k+t (for given k). I have elaborated a little more on the singularities in an update. – Dr. Wolfgang Hintze Jul 2 '18 at 12:46
• @ Bob Hanlon The question of the correct expression for the integral should be decided on mathematical ground, for instance by studying the type of singularities. Mathematically speaking there are no discontinuities in the integral, rather the singularities are simple poles in the variable m=k+t (for given k). I have elaborated a little more on the singularities in an update. – Dr. Wolfgang Hintze Jul 2 '18 at 13:19