Skip to main content
3 of 6
formula typesetting
Thies Heidecke
  • 8.8k
  • 34
  • 45

How to get a general answer using Integrate[]

The following two codes give conflicting answers, when integrating $\sin(k\pi x)\sin(2n\pi x)$ from $0$ to $1$, where both $k$ and $n$ are positive integers.

Code 1 assumes that $k$,$n$ are independent integers:

Integrate[Sin[k*Pi*x]*Sin[2*n*Pi*x],{x,0,1},
          Assumptions->{k\[Element]Integers,n\[Element]Integers}]

The result given by mathematica is 0.

Code 2 assumes that $k=2n$ and $n$ is integer:

Integrate[Sin[k*Pi*x]*Sin[2*n*Pi*x],{x,0,1},
          Assumptions->{n\[Element]Integers,k=2*n}]

The result is 1/2.

The result of Code 2 should be included in that of Code 1. It seems that Code 1 doesn't manage to give a general result. Isn't Code 1 supposed to give a general result?