In[1]:= Sum[Binomial[n, k]/Binomial[2 n, k]/k! (2 x)^k, {k, 0, n}]
Out[1]= 2^(-(1/2) - n) E^x x^(1/2 + n)
BesselI[1/2 (-1 - 2 n), x] Gamma[1/2 - n]
The correct answer is 1 for n=0 and Hypergeometric1F1[-n, -2 n, 2 x] for
integer n>0, which would be equal to the expression given by Mathematica if
n was not a positive integer.
Another form of the correct answer is
(2 x)^(n+1/2) E^x BesselK[n+1/2,x] n!/(2 n)!/Sqrt[Pi]
Is there a way to apply some assumptions to get the correct answer?
Alec
The polynomial form you are expecting (see In[1]) can be obtained by
taking the series expansion about x == 0 to the order n (see In[2]).
In[1]:= Table[Sum[Binomial[n, k]/Binomial[2 n, k]/k! (2 x)^k, {k, 0,
n}], {n, 0,
5}] // TableForm
Out[1]//TableForm=
1
1 + x
2
x
1 + x + --
3
2 3
2 x x
1 + x + ---- + --
5 15
2 3 4
3 x 2 x x
1 + x + ---- + ---- + ---
7 21 105
2 3 4 5
4 x x x x
1 + x + ---- + -- + -- + ---
9 9 63 945
In[2]:= Table[Series[Hypergeometric1F1[-n, -2 n, 2 x], {x, 0, n}] //
Normal, {n, 0,
5}] // TableForm
Out[2]//TableForm=
1
1 + x
2
x
1 + x + --
3
2 3
2 x x
1 + x + ---- + --
5 15
2 3 4
3 x 2 x x
1 + x + ---- + ---- + ---
7 21 105
2 3 4 5
4 x x x x
1 + x + ---- + -- + -- + ---
9 9 63 945
Regards,
--
Jean-Marc
Well, I can obtain it even without series expansion. For example, as
In[3]:= Hypergeometric1F1[-1, -2, 2 x]
Out[3]= 1 + x
The problem is that the answers given by Mathematica to the Sum problem, are
not the same - they are not polynomials, with the series expansion, or
without.
Alec
Here's one way to obtain the correct answer. The intermediate steps
are only formally correct but in the end the singularities cancel out:
In[1]:= Sum[
Binomial[n, k] (2 x)^k/(Binomial[2 n, k] k!) // FunctionExpand //
# /. Gamma[a_ - k] :> (-1)^k Pi Csc[a Pi]/Gamma[1 - a + k]&,
{k, 0, n}] //
FullSimplify // Simplify[#, Element[n, Integers]]&
Out[1]= 1/Gamma[1/2 + n] 2^-n ((-2)^n E^x Pi
Hypergeometric0F1Regularized[1/2 - n, x^2/4] + Sqrt[Pi] (-x)^(1 + n)
HypergeometricPFQRegularized[{1, 1}, {1 - n, 2 + n}, 2 x])
Maxim Rytin
m...@inbox.ru
Alec,
One can pass assumptions thanks to the function *Assuming[]* or the
option *Assumptions*, usually in combination with functions such as
Simplify or FullSimplify (when special functions are involved). For
instance,
In[1]:= Assuming[Element[n, Integers] && n > 0,
FullSimplify[
Sum[Binomial[n, k]/Binomial[2 n, k]/k! (2 x)^k, {k, 0, n}]]]
Out[1]= E^x Hypergeometric0F1[1/2 - n, x^2/4]
Note that the original result you got is equivalent for all n, indeed,
to the hypergeometric function you claim to be the correct solution.
In[2]:= s =
Sum[Binomial[n, k]/Binomial[2 n, k]/k! (2 x)^k, {k, 0, n}]
Out[2]= 2^(-(1/2) - n) E^x x^(1/2 + n)
BesselI[1/2 (-1 - 2 n), x] Gamma[1/2 - n]
In[3]:= FullSimplify[s]
Out[3]= E^x Hypergeometric0F1[1/2 - n, x^2/4]
In[4]:= FullSimplify[s == Hypergeometric1F1[-n, -2 n, 2 x]]
Out[4]= True
In[5]:= s /. n -> 0
Out[5]= E^x Cosh[x]
In[6]:= % // TrigToExp
Out[6]= 1/2 + E^(2 x)/2
The above result, however, does not match the following:
In[7]:= With[{n = 0},
Sum[Binomial[n, k]/Binomial[2 n, k]/k! (2 x)^k, {k, 0, n}]]
Out[7]= 1
(So the sum is now equal to one for n == 0, as you claimed.)
The *With[]* construct rewrite the sum as
Sum[Binomial[0, k]/Binomial[2 0, k]/k! (2 x)^k, {k, 0, 0}]]
*before* evaluating it.
Note that Mathematica fails in a weird way ( function == 0 ) checking
the equivalence of
In[8]:= FullSimplify[(2 x)^(n + 1/2) E^x BesselK[n + 1/2,
x] n!/(2 n)!/Sqrt[Pi] == Hypergeometric1F1[-n, -2 n, 2 x]]
Out[8]= (2^-n E^x x^(1/2 + n) BesselI[1/2 + n, x] Sec[n \[Pi]])/
Gamma[1/2 + n] == 0
Best regards,
-- Jean-Marc
But that is the wrong answer as well. The sum is a polynomial of x of degree
n, while Out[1] is not. For example,
In[2]:= % /. n -> 1
Out[2]= -(1/2) E^x x (-((2 Cosh[x])/x) + 2 Sinh[x])
while it should be 1+x.
> Note that the original result you got is equivalent for all n, indeed, to
> the hypergeometric function you claim to be the correct solution.
That is a bug. They are not equal for positive integer n. One is a
polynomial of x, and another one is not.
Alec
Hum, with series expansion they are (at least on my system). For instance,
In[1]:= s = Sum[Binomial[n, k]/Binomial[2 n, k]/k! (2 x)^k, {k, 0, n}]
Out[1]=
-(1/2) - n x 1/2 + n 1 1
2 E x BesselI[- (-1 - 2 n), x] Gamma[- - n]
2 2
In[2]:= Table[Series[s, {x, 0, n}] // Normal, {n, 0, 5}] // TableForm
Out[2]//TableForm=
1
1 + x
2
x
1 + x + --
3
2 3
2 x x
1 + x + ---- + --
5 15
2 3 4
3 x 2 x x
1 + x + ---- + ---- + ---
7 21 105
2 3 4 5
4 x x x x
1 + x + ---- + -- + -- + ---
9 9 63 945
In[3]:= FullSimplify[s]
Table[Series[%, {x, 0, n}] // Normal, {n, 0, 5}] // TableForm
Out[3]=
2
x 1 x
E Hypergeometric0F1[- - n, --]
2 4
Out[4]//TableForm=
1
1 + x
2
x
1 + x + --
3
2 3
2 x x
1 + x + ---- + --
5 15
2 3 4
3 x 2 x x
1 + x + ---- + ---- + ---
7 21 105
2 3 4 5
4 x x x x
1 + x + ---- + -- + -- + ---
9 9 63 945
In[5]:= Table[Hypergeometric1F1[-n, -2 n, 2 x], {n, 0, 5}] // TableForm
Out[5]//TableForm=
1
1 + x
2
x
1 + x + --
3
2 3
2 x x
1 + x + ---- + --
5 15
2 3 4
3 x 2 x x
1 + x + ---- + ---- + ---
7 21 105
2 3 4 5
4 x x x x
1 + x + ---- + -- + -- + ---
9 9 63 945
In[7]:= Table[FullSimplify[s] == Hypergeometric1F1[-n, -2 n, 2 x], {n,
0, 5}, {x, 1,
5}]
Out[7]= {{False, False, False, False, False}, {False, False, False, False,
False}, {False, False, False, False, False}, {False, False, False, False,
False}, {False, False, False, False, False}, {False, False, False, False,
False}}
In[9]:= $Version
Out[9]= "6.0 for Mac OS X x86 (64-bit) (May 21, 2008)"
Best regards,
--
Jean-Marc
That just tells that the beginning of the series is the same. But the rest
should be subtracted to get the correct answer - that's generally how the
answer with BesselK appears - as a result of subtracting of 2 expressions
with BesselI.
> In[3]:= FullSimplify[s]
> Table[Series[%, {x, 0, n}] // Normal, {n, 0, 5}] // TableForm
The same here - if you took more than n terms from the series, you would see
the difference. 1 is not equal to E^(2x) even if the first term of Taylor
series is the same :)
> In[7]:= Table[FullSimplify[s] == Hypergeometric1F1[-n, -2 n, 2 x], {n,
> 0, 5}, {x, 1,
> 5}]
>
> Out[7]= {{False, False, False, False, False}, {False, False, False, False,
> False}, {False, False, False, False, False}, {False, False, False, False,
> False}, {False, False, False, False, False}, {False, False, False, False,
> False}}
That, certainly, is correct - the answer given by Mathematica is not equal
to the correct answer (as I said in the original post).
Alec
> Here's one way to obtain the correct answer. The intermediate steps
> are only formally correct but in the end the singularities cancel out:
>
> In[1]:= Sum[
> Binomial[n, k] (2 x)^k/(Binomial[2 n, k] k!) // FunctionExpand //
> # /. Gamma[a_ - k] :> (-1)^k Pi Csc[a Pi]/Gamma[1 - a + k]&,
> {k, 0, n}] //
> FullSimplify // Simplify[#, Element[n, Integers]]&
>
> Out[1]= 1/Gamma[1/2 + n] 2^-n ((-2)^n E^x Pi
> Hypergeometric0F1Regularized[1/2 - n, x^2/4] + Sqrt[Pi] (-x)^(1 + n)
> HypergeometricPFQRegularized[{1, 1}, {1 - n, 2 + n}, 2 x])
That seems to be correct answer. It is an interesting way of obtaining it.
Is there a way to simplify it to one of 2 other forms of the correct answer
that I mentioned in the original post?
Alec
> Mathematica gives the wrong answer to the following sum,
>
> In[1]:= Sum[Binomial[n, k]/Binomial[2 n, k]/k! (2 x)^k, {k, 0, n}]
>
> Out[1]= 2^(-(1/2) - n) E^x x^(1/2 + n)
> BesselI[1/2 (-1 - 2 n), x] Gamma[1/2 - n]
>
> The correct answer is 1 for n=0 and Hypergeometric1F1[-n, -2 n, 2 x] for
> integer n>0, which would be equal to the expression given by Mathematica if
> n was not a positive integer.
>
> Another form of the correct answer is
>
> (2 x)^(n+1/2) E^x BesselK[n+1/2,x] n!/(2 n)!/Sqrt[Pi]
>
> Is there a way to apply some assumptions to get the correct answer?
>
> Alec
>
Hello Alec,
Thank you for reporting the problem with the answer returned by Sum in the
above example. As noted by you, this sum can be evaluated in terms of
Hypergeometric1F1.
A partial workaround for the problem is to introduce a parameter 'a'
as shown in In[2] below, to obtain a Hypergeometric1F1 function.
The incorrect behavior in your example is caused by
auto-simplification of this hypergeometric function (see In[4] below).
=========================
In[2]:= Sum[(Binomial[n, k]/Binomial[a*n, k]/k!)*(2*x)^k, {k, 0, n}]
Out[2]= Hypergeometric1F1[-n, -(a n), 2 x]
In[3]:= Table[% /. {a -> 2}, {n, 0, 3}] // InputForm
Out[3]//InputForm= {1, 1 + x, 1 + x + x^2/3, 1 + x + (2*x^2)/5 + x^3/15}
In[4]:= %% /. {a -> 2} // InputForm
Out[4]//InputForm=
2^(-1/2 - n)*E^x*x^(1/2 + n)*BesselI[(-1 - 2*n)/2, x]*Gamma[1/2 - n]
==========================
I apologize for the confusion caused by this problem.
Sincerely,
Devendra Kapadia,
Wolfram Research, Inc.
Devendra,
Thank you very much!
It was, probably, my first post in the Mathematica group and wow - what a
difference comparing to other CAS newsgroup or forum where I used to post. I
got a very nice reply, the problem was addressed, a workaround was
suggested, and I wasn't even asked to fill the SCR (software change
request.) Fantastic!
Great work, guys!
Alec Mihailovs,
Mihailovs, Inc.