# FullSimplify gives wrong answer when operating on HypergeometricPFQ

When I try to simplify this hypergeometric function

FullSimplify[HypergeometricPFQ[{1/2 - n/2}, {-(1/2) - n/2}, -a^2]]


Mathematica 10.0.1.0 returns

(Exp[-a^2] (1 + n + 2 a^2))/(1 + n)


but if I compare the two expressions for different integer values of n,

Table[(Exp[-a^2] (1 + 2 a^2 + n))/(1 + n) ==
HypergeometricPFQ[{1/2 - n/2}, {-(1/2) - n/2}, -a^2], {n, 0, 6}]


they are different for odd n

{True, 1/2 (2 + 2 a^2) E^-a^2 == 1, True, 1/4 (4 + 2 a^2) E^-a^2 == 1 - a^2/2,
True, 1/6 (6 + 2 a^2) E^-a^2 == 1 - (2 a^2)/3 + a^4/6, True}


What's going on?

(This behavior persists if I use FunctionExpand[] in place of FullSimplify[], since the latter calls the former.)

• Simply put: Hypergeometric1F1[] degenerates to a polynomial if its upper parameter is a nonpositive integer. Unfortunately, the generic solution returned by FunctionExpand[]/FullSimplify[] does not take this into account. – J. M.'s ennui Oct 14 '15 at 16:17
• Are you saying that the result returned by FunctionExpand[] is false when the upper parameter is a nonpositive integer? – Jess Riedel Oct 14 '15 at 16:23
• Pretty much, yes, due to the exponential factor not being taken care of. If you're interested, I can write a solution detailing how to derive the correct result in that special case. – J. M.'s ennui Oct 14 '15 at 16:25
• Terrifying. Yes, I would be very grateful for a solution. The hypergeometric function is a series coefficient in a Taylor expansion I am working with, for which I really need a simple expression that I can further operate on. – Jess Riedel Oct 14 '15 at 16:28

To recap, the result returned by FunctionExpand[Hypergeometric1F1[1/2 - n/2, -(1/2) - n/2, -a^2]] is a generic solution, which is intended to be correct in most cases. Unfortunately, the case of odd n is not part of those cases:

Table[Hypergeometric1F1[1/2 - n/2, -(1/2) - n/2, -a^2] ==
Exp[-a^2] (1 + 2 a^2 + n)/(1 + n) // FullSimplify // TrueQ, {n, 10}]
{False, True, False, True, False, True, False, True, False, True}


To handle the odd n case, we first do a preliminary transformation:

Hypergeometric1F1[1/2 - n/2, -(1/2) - n/2, -a^2] /. n -> 2 k + 1 // Simplify
Hypergeometric1F1[-k, -1 - k, -a^2]


which shows the source of the failure: the case of odd n results in a Kummer function with a nonpositive numerator parameter, which is precisely the degenerate polynomial case. To explicitly deal with this, we go back to the defining series for ${}_1 F_1$:

$${}_1 F_1\left({{a}\atop{b}}\mid z\right)=\sum_{j=0}^\infty \frac{(a)_j}{(b)_j}\frac{z^j}{j!}$$

For the special case under consideration, we have

$${}_1 F_1\left({{-k}\atop{-1-k}}\mid -a^2\right)=\sum_{j=0}^\infty \frac{(-k)_j}{(-1-k)_j}\frac{\left(-a^2\right)^j}{j!}$$

Since $(-k)_j=0$ if $j>k$, the series terminates:

$${}_1 F_1\left({{-k}\atop{-1-k}}\mid -a^2\right)=\sum_{j=0}^k \frac{(-k)_j}{(-1-k)_j}\frac{\left(-a^2\right)^j}{j!}$$

Using

FullSimplify[Pochhammer[-k, j]/Pochhammer[-1 - k, j]]
1 - j/(1 + k)


we thus have

Sum[(1 - j/(1 + k)) (-a^2)^j/j!, {j, 0, k}] // FullSimplify
((-a)^k a^(4 + k) E^a^2 + (1 + a^2 + k) Gamma[2 + k, -a^2])/
(E^a^2 (1 + k)*Gamma[2 + k])


We can now undo the earlier substitution:

s[n_] = % /. k -> (n - 1)/2 // FullSimplify
(2 ((-a)^((-1 + n)/2) a^((7 + n)/2) E^a^2 + ((1 + 2 a^2 + n)
Gamma[(3 + n)/2, -a^2])/2))/(E^a^2 (1 + n) Gamma[(3 + n)/2])


The rather complicated closed form gives no indication that it is in fact a polynomial. Nevertheless,

Table[Hypergeometric1F1[1/2 - n/2, -(1/2) - n/2, -a^2] == s[n] //
FullSimplify, {n, 1, 11, 2}]
{True, True, True, True, True, True}

s[7] // FullSimplify
(24 - 18*a^2 + 6*a^4 - a^6)/24

• Tremendously helpful. Am I crazy in calling this a bug, since the hypergeometric function was returned by SeriesCoefficient[], which is expected to use integers? Is there any way to avoid incorrect simplifications by FullSimplify[] in the future that doesn't require detailed knowledge of the relevant special function? – Jess Riedel Oct 14 '15 at 17:15
• Again, by design, the results obtained by simplification functions are only generically correct. It is entirely possible to have a result that is not valid for a countable set of values. Thus, it is always in your best interest to perform sanity checks on whatever results you get, whether in Mathematica or a different CAS. – J. M.'s ennui Oct 14 '15 at 17:19