# Is simplify giving a "not always" correct answer here?

A result like this appears as one of the terms when I compute coefficients in a Fourier Series:

expr =(Sin[n*Pi])/((-4 + n^2))


If I simplify all my terms, this happens:

Simplify[expr, Assumptions -> Element[n, Integers]] (*returns a zero*)


Which is true except if n=-2 or 2:

Limit[expr, n -> 2] (*give Pi/4*)


Shouldn't Simplify catching that?

\$Version

(* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *)

Clear["Global*"]


From the "Possible Issues" section of the documentation for Simplify, "results of simplification of expressions with singularities are uncertain"

expr = (Sin[n*Pi])/((-4 + n^2));


The general result would be

expr = Module[{
roots = n /. Solve[Denominator[expr] == 0, n]},
Simplify[
Piecewise[{
{expr, And @@ Thread[roots != n]},
Sequence @@ ({Limit[expr, n -> #], n == #} & /@ roots)}],
Element[n, Integers]]]
`

• Yup. I should have looked at Possible Issues before posting. Thanks @BobHanlon. Jan 26, 2021 at 21:05