5

Upon evaluating the integral

Integrate[Exp[-x^(2 n)] x^(2 k), {x, -\[Infinity], \[Infinity]}, 
    Assumptions -> {n > 0, k > 0, (n | k) \[Element] Integers}]

I get the result ($Version="11.1.0 for Mac OS X x86 (64-bit) (March 16, 2017)")

ConditionalExpression[
    (((-1)^(2 n))^(-((1 + 2 k)/(2 n))) ((-1)^(2 k) + ((-1)^(2 n))^((1 + 2 k)/(2 n))) 
    Gamma[(1 + 2 k)/(2 n)])/(2 n), 
    C[1] \[Element] Integers && 
    n < 1/4 + C[1] && C[1] >= 1 && C[1] < 1/4 + n]

My question is: what is C[1] doing there? It's a definite integral, so there should be no constant of integration. Moreover, it doesn't show up in the "value" part of the ConditionalExpression. Putting the inequalities with n together just gives n < 1/2 + n, which is always true, so I think the only thing that it enforces is that (saturating the bound on C[1]), 1 ≤ 1/4 + n so that n must be at least 1 (if it's going to be an integer). But I already told Mma that it's a positive integer, so in the end those conditionals should all be satisfied. So: what's the point of C[1] in this result?

As an added (but not super-important) follow-up, if I tell Mma that n and k are integers, why doesn't it simplify (-1)^(2 k) or the other squares of -1?

Update as of Version 13.0

As of $Version == "13.0.0 for Mac OS X x86 (64-bit) (December 3, 2021)" the result I get is

(((-1)^(2 n))^(-((1+2 k)/(2 n))) ((-1)^(2 k)+((-1)^(2 n))^((1+2 k)/(2 n))) Gamma[(1+2 k)/(2 n)])/(2 n)

which, at least, has eliminated the unneeded mystery constant. Of course, it's still not leveraging all of the assumptions, since

FullSimplify[%, 
    Assumptions -> {n > 0, k > 0, (n | k) \[Element] Integers}]

yields Gamma[(1+2 k)/(2 n)]/n.

So, why doesn't Integrate actually leverage the assumptions?

evanb
  • 6,026
  • 18
  • 30
  • the C[1] is not an integration constant, it is part of the conditional on n – george2079 May 30 '17 at 17:12
  • Why is there an arbitrary constant introduced in order to formulate a conditional on n that's redundant with what I already specified? – evanb May 30 '17 at 17:15
  • IDK. It is redundant, it says n must be +/- 1/4 of an integer >=1 , ie true for all integers > 0. FWIW v10.1 just gives the (unsimplified) expression, not conditional. – george2079 May 30 '17 at 17:29
  • So, what's the point of C[1] in the result? Also it doesn't say n must be ±1/4 of an integer, since C[1] need not be an integer. – evanb May 30 '17 at 18:41
  • If it's changed since v10.1, that's also a mystery! – evanb May 30 '17 at 18:42
  • Version 12.3.1 on Widows 10 answers $$ \frac{\left((-1)^{2 n}\right)^{-\frac{2 k+1}{2 n}} \left(\left((-1)^{2 n}\right)^{\frac{2 k+1}{2 n}}+(-1)^{2 k}\right) \Gamma \left(\frac{2 k+1}{2 n}\right)}{2 n}.$$ – user64494 Dec 15 '21 at 12:21
  • Aha, so this one has been fixed for a while! (Though still no recognition that given the Assumptions, (-1)^2n = 1 (for example).) – evanb Dec 15 '21 at 12:22
  • In addition, Integrate[Exp[-x^(2 n)] x^(2 k), {x, -\[Infinity], \[Infinity]}, Assumptions -> {n > 0, k > 0}] produces the same result. – user64494 Dec 15 '21 at 12:36

2 Answers2

8

In:

Assuming[{n > 0 && k > 0 && {n, k} \[Element] Integers}, 
 Integrate[Exp[-x^(2 n)] x^(2 k), {x, -\[Infinity], \[Infinity]}]]

Out:

Mathematica graphics

If anyone is interested in it, you can check the implemention.

Needs["GeneralUtilities`"]
PrintDefinitions[Integrate]
PrintDefinitions[Assuming]
webcpu
  • 3,182
  • 12
  • 17
4

I believe the C[1] comes from this:

Reduce[k > 0 && n > 0 && Re[(-1)^(1 + 2 n)] < 0, Complexes]
Simplify[%, (k | n) ∈ Integers && k >= 1 && n >= 1]
(*
  C[1] ∈ Integers && 
    k > 0 && (0 < n < 1/4 || (C[1] >= 1 && 1/4 (-1 + 4 C[1]) < n < 1/4 (1 + 4 C[1])))
  C[1] ∈ Integers && C[1] >= 1 && C[1] < 1/4 + n && n < 1/4 + C[1]
*)

One can get the Reduce commands used in Integrate[] with this:

Trace[
 Integrate[Exp[-x^(2 n)] x^(2 k), {x, -∞, ∞}, 
  Assumptions -> {n > 0, k > 0, (n | k) ∈ Integers}],
 _Reduce,
 TraceInternal -> True]

It's hard to say exactly what Reduce is being used for beyond the easy guess that it has something to do with convergence.

The follow-up question about simplifying (-1)^(2 k) is a key to another workaround:

Integrate[Exp[-x^(2 n)] x^(2 k), {x, -∞, ∞}, 
 Assumptions -> {n > 0, k > 0, (n | k) ∈ Integers, (-1)^(2 k) == 1, (-1)^(2 n) == 1}]
(*  Gamma[(1 + 2 k)/(2 n)]/(2 n)  *)

And Mathematica can simplify (-1)^(2k):

Simplify[{(1)^(2 k), (-1)^(1 + 2 k)}, k ∈ Integers]
(*  {1, -1}  *)

Simplify uses the assumptions from $Assumptions, which are added to by Assuming; it is probably why @UnchartedWorks's workaround works, and perhaps why @Daniel warns against it.

Some related Q&A:

Usage of Assuming for Integration

Solution to a specific problem caused by generic simplification

Simplify is excluding indeterminate expression from output

What is a "generic case"?

Michael E2
  • 235,386
  • 17
  • 334
  • 747