4

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?

Craig Carter
  • 4,416
  • 16
  • 28

1 Answers1

5
$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]]]

enter image description here

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198