# Simplification of integrals depending on a parameter [duplicate]

Assuming[Element[n, Integers], Integrate[Sin[x]*Sin[n*x],{x,0,Pi}]]

returns 0, which is obviously wrong for n=1.

Assuming[n==1, Integrate[Sin[x]*Sin[n*x],{x,0,Pi}]]

does return Pi/2 (so in particular not 0).

Just evaluating the integral yields

-Sin[n*Pi]/(-1+n^2)

which is indetermined for n=1.

Can someone explain to me what Mathematica is doing and how to obtain a correct result?

-

## marked as duplicate by Artes, rcollyer, Michael E2, Szabolcs, bobthechemistFeb 11 '14 at 15:40

The last expression is not undetermined if you take the limit Limit[-(Sin[n \[Pi]]/(-1 + n^2)), n -> 1]. –  b.gatessucks Feb 11 '14 at 11:23
Yes, l'Hospital works, however Mathematica does not seem to use that for simplification. Simplify[-Sin[n Pi]/(-1+n^2), Assumptions -> Element[n,Integers]] also gives 0 . –  chris Feb 11 '14 at 11:29
I answered a similar question on stackoverflow, and I don't have time right now to transcribe it here. –  rcollyer Feb 11 '14 at 12:46
In document (F1) of Simplify and FullSimplify, the Possible Issues section is related to this problem. –  Yi Wang Feb 11 '14 at 12:55
Thanks for pointing me to the Possible Issues section. –  chris Feb 11 '14 at 13:33

This is easy to see with Integrate[Cos[n x], {x, 0, Pi}] which equals $\pi$ when $n=0$, but $0$ otherwise. –  rcollyer Feb 11 '14 at 13:40