# Simplifying Integrals

How can I get the expected results of 2 from this integral?

Assuming[{U, k} \[Element] Reals && k > 0, (
Integrate[
2 (U Exp[\[ImaginaryJ] k x])^2, {x, -\[Infinity], \[Infinity]}] //
HoldForm)/(
Integrate[(U Exp[\[ImaginaryJ] k x])^2, {x, -\[Infinity], \
\[Infinity]}] // HoldForm) // FullSimplify]

• The integral $\int_{-\infty }^{\infty } e^{2 i k x} \, dx$ diverges and Matematica reports it. In view of it I find the question meaningless. Commented Jan 8, 2022 at 5:35
• As the integral diverges, you have Infinity/Infinity what is not defined. The best you can do is to take the definite integral from -a to a and take the limit a->Infinity. Commented Jan 8, 2022 at 10:15
• @DanielHuber: Its Cauchy pprincipal value does not exists as Limit[Integrate[(Exp[\[ImaginaryJ] k x])^2, {x, -a, a}, Assumptions -> a > 0], a -> Infinity] produces and the same with the denominator. Commented Jan 8, 2022 at 17:10
• @user64494, I interpreted the question differently: Why do the integrals not cancel no matter what the integrand is? In any case, due to HoldForm the integral does not evaluate at all. The issue then is, how to pull 2 from within Integrate in the numerator, and then how to convince Mathematica to cancel the two identical expressions. Experienced users of this site know what to do, but it is not surprising that those less experienced do not. By the way, it took me a few minutes to realize that HoldForm needed to be replaced by Unevaluated. Commented Jan 8, 2022 at 18:30
• @bbgodfrey Thank you, your comment and answer are very helpful. Commented Jan 10, 2022 at 4:01

A transformation function must be defined to extract the leading number from within Integrate. Also, HoldForm should be replaced by Unevaluated.

tf[e_] := e /. Integrate[Times[n_?NumericQ, z1__], z2_] :> n Integrate [z1, z2]

Assuming[{U, k} ∈ Reals && k > 0, (
(Integrate[2 (U Exp[ k x])^2, {x, -∞, ∞}] // Unevaluated)/
(Integrate[(U Exp[ k x])^2, {x, -∞, ∞}] // Unevaluated)) //
FullSimplify[#, TransformationFunctions -> {Automatic, tf}] &]
(* 2 *)

• TransformationFunctions seems to be a very useful function that I do not know previously. Thank you for the answer. Commented Jan 10, 2022 at 4:08
• @bakerryd123, Check out the ComplexityFunction option too. Best wishes. Commented Jan 10, 2022 at 5:26
• Nice suggestion, thanks! Commented Jan 10, 2022 at 16:02