4
$\begingroup$

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?

$\endgroup$
1
5
$\begingroup$
$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

$\endgroup$
1
  • $\begingroup$ Yup. I should have looked at Possible Issues before posting. Thanks @BobHanlon. $\endgroup$ – Craig Carter Jan 26 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.