2

Let's say I would like to find a symbolic form for the integral $$\int_0^{2\pi}\sin^nx\,\mathrm{d}x$$with the added condition that $n$ is not only an integer, but an even one at that. Can this be done?

I've tried

Integrate[Sin[x]^n, {x, 0, 2Pi}, Assumptions -> {n == 2k && k ϵ Integers}]

but this seems to ignore the k altogether.

I didn't expect this to work, but I've also tried using

Assumptions -> {n ϵ Integers && EvenQ[n] == True}

but that only returns Integrate[..., Assumptions -> {False}].

Edit: I realize I could replace n with 2n and just use Assumptions -> n ϵ Integers, but is there a way to compound the even/integer conditions in Assumptions?

bbgodfrey
  • 61,439
  • 17
  • 89
  • 156
user170231
  • 1,611
  • 1
  • 11
  • 17

3 Answers3

1
Assuming[{n/2 ∈ Integers},
  Integrate[Sin[x]^n, {x, 0, 2 π}]] //
 TraditionalForm

enter image description here

Assuming[{n >= 0 && n/2 ∈ Integers},
  Integrate[Sin[x]^n, {x, 0, 2 π}]] //
 TraditionalForm

enter image description here

Assuming[{n >= 0 && n/2 ∈ Integers},
  Integrate[Sin[x]^n, {x, 0, 2 π}] //
   FullSimplify] //
 TraditionalForm

enter image description here

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

It's actually rather easy to specify the evenness or oddness of an integer in an assumption:

Assuming[Mod[k, 2] == 0, Integrate[Sin[x]^k, {x, 0, 2 π}]]
   (* (2 Sqrt[π] Gamma[(1 + k)/2])/Gamma[1 + k/2] *)

Assuming[Mod[k, 2] == 1, Integrate[Sin[x]^k, {x, 0, 2 π}]]
   (* 0 *)
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
0

I tried:

Integrate[Sin[x]^(2 n), {x, 0, 2 Pi}, 
Assumptions -> {n >= 0 && n \[Element] Integers}]
//TraditionalForm

$$\frac{\sqrt{\pi } \left((-1)^{2 n}+1\right) \Gamma \left(n+\frac{1}{2}\right)}{\Gamma (n+1)}$$

bobbym
  • 2,628
  • 2
  • 15
  • 20