# Integrating to solve for normalization factors

For $$f(x)$$ solve for its normalization factor as follows: $$\left\{ \begin{array}{l} f\left( x \right) =A\exp \left( -\frac{\left( x-x_0 \right) ^2}{2\sigma ^2} \right)\\ A=\frac{1}{\sigma \sqrt{2\pi}}\\ \end{array} \right.$$

sol1 = Simplify[
Integrate[
Exp[-1/2 ((x - x0)/\[Sigma])^2], {x, -Infinity, Infinity}],
Assumptions -> Element[\[Sigma], PositiveReals]];
SolveValues[A sol1 == 1, A]

{1/(Sqrt[2 \[Pi]] \[Sigma])}


If $$f(x)$$ is expanded to $$g(x)$$, it is not possible to solve for $$B$$ when solving for its normalization factor using Mathematica. $$g\left( x \right) =B \exp\left( -\frac{\left( x-x_0 \right) ^{2n}}{2\sigma ^{2n}} \right)$$

sol2 = Integrate[
Exp[-1/2 ((x - x0)/\[Sigma])^(2 n)], {x, -Infinity, Infinity}]
SolveValues[B sol2 == 1, B]


How do you correctly find the expression for $$B$$?

First note that the shift : (x - x0) is not important because we integrate over all reals .

Then we can make a change of variables : x -> x/sigma what gives the integral

int= 1/\[Sigma] Integrate[Exp[-1/2 x^(2 n)], {x, -Infinity, Infinity}]


B is now the inverse of "int":

B= 1/int =

• FullSimplify[(2^((1/2)/n) ((-1)^(2 n))^(-(1/2)/n) (1 + ((-1)^(2 n))^((1/2)/n)) Gamma[1 + 1/(2 n)])/\[Sigma], n \[Element] PositiveIntegers] gives a much simpler form.
– JimB
Aug 24, 2023 at 23:25

Without loss of generality one can set $$x_0=0$$ and that won't change the constant of integration. The constant of integration is

$$\frac{1}{2\ 2^{\frac{1}{2 n}} \sigma \Gamma \left(\frac{2 n+1}{2 n}\right)}$$

as seen from the following:

Table[{n, 1/Integrate[Exp[-x^(2 n)/(2 σ^(2 n))], {x, -∞, ∞}, Assumptions -> σ > 0]},
{n, 1, 10}]


Sometimes Mathematica will only perform the integration with specific values of $$n$$ and the above approach becomes necessary. A more direct approach for this particular set of probability densities is the following:

const = 1/Integrate[Exp[-x^(2 n)/(2 σ^(2 n))], {x, -∞, ∞},
Assumptions -> {σ > 0, n ∈ PositiveIntegers}];
const = FullSimplify[const, Assumptions -> n ∈ PositiveIntegers]
(* (2^(-(1/2)/n) n)/(σ Gamma[1/(2 n)]) *)


$$\frac{2^{-\frac{1}{2 n}} n}{\sigma \Gamma \left(\frac{1}{2 n}\right)}$$

• The whole point of the question is to avoid the human intervention such as this. Aug 24, 2023 at 16:47
• @DavidG.Stork I can understand not wanting to think for some folks might be desirable based on your comment.
– JimB
Aug 24, 2023 at 16:57
• No... The point is to think about computer algebra... the whole point of this website. If the question was just about math, it would belong on math.SE. On this site we want to understand the strengths and limitations and methods of using computer algebra. I think it likely that once we get a solution to this problem (likely involving IntegrateChangeVariables), it will apply to numerous other problems, thereby empowering them (us) to address ever more subtle, difficult, and complex problems. Aug 24, 2023 at 18:18
• @DavidG.Stork I was too subtle with my response to your first comment. Your first comment was presumptuous and obnoxious. "On this site we...." I'm glad you're not in charge of this site.
– JimB
Aug 24, 2023 at 21:52
• write: "Your first comment was presumptuous and obnoxious." Yet got an independent upvote. To say this site (Mathematica.SE) is focused on computer algebra, rather than solving math problems by traditional non-computer methods is "presumptuous"? Really? Aug 24, 2023 at 22:31