# Equivalent (?) definitions of function gives different answers

I have a function as follows:

G[n_, Q_, eta_] := (-1)^(n + 1)*(4 Q - 2 n + 1)! (n - 1)! (1 -eta^2)^(2Q- n) eta^2 JacobiP[n - 1, 2, 4 Q + 1 - 2 n, 1 - 2 eta^2]/(4 Q - n)!;


And another one which is supposed to equal G evaluated at n+1:

Gnp12[n_, Q_, eta_] := (-1)^n (4 Q - 1 - 2 n)!/((4 Q - n - 1)! (4 Q + 1 -n)!) eta^2 (n + 2)!*Sum[Binomial[n, m]*(4 Q + 1 - n + m)!/(m + 2)! (-1)^m eta^(2 m), {m, 0, n}] Sum[ Binomial[2 Q - n - 1, j] (-1)^j eta^(2 j),{j, 0, 2 Q - n - 1}];


I test this for a few values:

Table[G[n + 1, Q, eta]/Gnp12[n, Q, eta] // FullSimplify, {n, 5}] // MatrixForm


Which gives a vector of ones as expected (the first one is not simplified for some reason).

Next I want to simplify the expression for Gnp12 a bit and write it as a double sum:

Gnp12[n_, Q_,eta_] := (-1)^n (4 Q - 1 - 2 n)!/((4 Q - n - 1)! (4 Q + 1 - n)!) eta^2 (n + 2)!*Sum[Binomial[n, m]*(4 Q + 1 - n + m)!/(m + 2)! (-1)^m eta^(2 m) Binomial[2 Q - n - 1, j] (-1)^j eta^(2 j), {j, 0, 2 Q - n - 1}, {m, 0, n}];


And try to test it again:

Table[G[n + 1, Q, eta]/Gnp12[n, Q, eta] // FullSimplify, {n, 5}] // MatrixForm


To my surprise this time I get ComplexInfinity at n=4 and 5 because Gnp12 evaluates to zero. Why does this happen? Aren't the two definitions equivalent?

• I find G[n + 1, Q, eta]/Gnp12[n, Q, eta] simplifies to 1 for both definitions of Gnp12. The table is somewhat irrelevant as the ratio does not depend on n (or Q or eta). – Quantum_Oli Apr 11 '16 at 12:46
• Really?? That is weird.. Do I need to update Mathematica or something? I have version 10.3. I guess the table is irrelevant if you're convinced that Gnp12 is equivalent to G at n+1 but that is what I wanted to double check. Is that what you mean? – jorgen Apr 11 '16 at 12:50
• I'm on 10.3 as well. Yeah both Gnp12 are equivalent to G at n+1: i.imgur.com/QNldS7y.png – Quantum_Oli Apr 11 '16 at 13:03

Simplify your functions when they are defined.

G[n_, Q_, eta_] = (-1)^(n + 1)*(4 Q - 2 n + 1)! (n - 1)! (1 - eta^2)^(2 Q -
n) eta^2 JacobiP[n - 1, 2, 4 Q + 1 - 2 n, 1 - 2 eta^2]/(4 Q - n)! //
FullSimplify;

Gnp12[n_, Q_,
eta_] = (-1)^
n (4 Q - 1 - 2 n)!/((4 Q - n - 1)! (4 Q + 1 - n)!) eta^2 (n + 2)!*
Sum[Binomial[n, m]*(4 Q + 1 - n + m)!/(m + 2)! (-1)^m eta^(2 m), {m, 0,
n}] Sum[Binomial[2 Q - n - 1, j] (-1)^j eta^(2 j), {j, 0,
2 Q - n - 1}] // FullSimplify;

Gnp122[n_, Q_,
eta_] = (-1)^
n (4 Q - 1 - 2 n)!/((4 Q - n - 1)! (4 Q + 1 - n)!) eta^2 (n + 2)!*
Sum[Binomial[n, m]*(4 Q + 1 - n + m)!/(m + 2)! (-1)^m eta^(2 m) Binomial[
2 Q - n - 1, j] (-1)^j eta^(2 j), {j, 0, 2 Q - n - 1}, {m, 0, n}] //
FullSimplify;


Gnp12 and Gnp122 are simplified to identical expressions

Gnp12[n, Q, eta] === Gnp122[n, Q, eta]

(*  True  *)


The representations are equivalent for all n

G[n + 1, Q, eta] == Gnp12[n, Q, eta] == Gnp122[n, Q, eta] // FullSimplify

(*  True  *)


Table[G[n + 1, Q, eta]/Gnp12[n, Q, eta] // FullSimplify, {n, 5}]