# Why is Mathematica telling me that two equal sequences are unequal?

These two sequences are identical:

a[n_] := 1/Gamma[(1 - n)/2]

c[n_] := If[EvenQ[n], 1/Gamma[(1 - n)/2], 0]

Table[a[n], {n, 0, 1000}] == Table[c[n], {n, 0, 1000}]
(* True *)


Nevertheless, FullSimplify[a[n] == c[n], {n \[Element] Integers, n >= 0}] returns False. Why is this?

v12.0.0.0

• The EvenQ problem aside: Is a[1] undefined or zero? Mathematically, 1 is not in the domain. Computationally, Gamma returns ComplexInfinity, and 1/ComplexInfinity evaluates to 0. Consider: Reduce[FunctionDomain[1/Gamma[(1 - n)/2], n] && n \[Element] Integers]. Also, this returns the "mathematical" result: c[n_] := If[(1 - n)/2 \[NotElement] Integers, 1/Gamma[(1 - n)/2], 0]; FullSimplify[a[n] == c[n], {n \[Element] Integers, n >= 0}] Commented Jul 18, 2020 at 20:16

EvenQ[n] is False for symbolic n. EvenQ will only return True for literal even integers, and False for everything else. It is a convention in Mathematica that any function ending in Q returns either True or False for any input.
Think of EvenQ as a function in the programming sense, not the mathematical sense.
You can detect this problem by looking at what c[n] evaluates to (as opposed to e.g. what c[2] evaluates to).
Generally, a possible solution could be c[n_] := Piecewise[{{1/Gamma[(1 - n)/2], Mod[n, 2] == 0}}, 0]. This won't quite work here. FullSimplify will return Mod[n,2] == 0 as it can't figure out that a[n] == 0 for any odd n.
• Symbolic processing, Simplify and friends, cannot generally reason about things that are functions in the programming sense. Commented Jul 18, 2020 at 19:58
• @JohnDoty It's not that they cannot reason, but that FullSimplify never even sees that EvenQ. Evaluate c[n]. There is no EvenQ there. It's gone, evaluated to False. Commented Jul 18, 2020 at 20:11
• One might imagine an easy fix: define c[n_Integer] := .... But then, Simplify has no way to look inside the definition and reason about the algorithm. Commented Jul 18, 2020 at 20:33