# How to handle undefined Integral results for excluded conditions in Mathematica

I have a mathematical function where both input parameters x and y are real numbers within the interval [−π,π]:

F[x_, y_] := (16 Sin[2*x]^2 Sin[y/2]^2)/(3 + Cos[4*x] - 2 Cos[y] Sin[2*x]^2)


I performed the integration of F with respect to y, aiming to obtain an expression dependent on x:

\$Assumptions = {x \[Element] Reals, y \[Element] Reals};
InterF = FullSimplify[Integrate[F[x, y], {y, -Pi, Pi}]]


This integration yields the following conditional expression:

If Abs[Tan[x]]!=1&&Abs[Cot[x]]!=1
16*Pi*Cos[x]^2   Abs[Tan[x]]>=1&&Abs[Cot[x]]<1
16*Pi*Sin[x]^2   True


However, evaluating InterF at x=Pi/4 (ie., InterF/. {x -> Pi/4}) results in Undefined because the conditions in the resultant expression do not include this specific case where x=Pi/4.

I attempted setting GenerateConditions -> False, which did not resolve the issue.

Question: What should be done when a specific condition - in this case, If Abs[Tan[x]]!=1&&Abs[Cot[x]]!=1 — isn’t met? How can I achieve a defined integral result for x = Pi/4, especially if the conditions don't cover this case?

Is it okay to just pick one of the conditional expressions? Since the function F[x_, y_] and its integral could be quite complex (instead of the straightforward example here), I'm unsure if choosing arbitrarily is appropriate. Any guidance or advice would be greatly appreciated. Thank you in advance.

Notably: F[x, y] /. {x -> Pi/4} // Simplify gives 4, which means the integral result will be 8*Pi. However, I don't want to set the value of x before integrating, as this is just a simple example here and I need an expression in terms of x for later evaluations with different x values.

• Try: Limit[InterF, x -> Pi/4] ? Commented Jul 14 at 12:17
• You can evaluate e.g. Assuming[ Reduce[ -Pi <= x <= Pi && (Abs[Tan[x]] == 1 || Abs[Cot[x]] == 1), x], FullSimplify[Integrate[ F[x, y], {y, -Pi, Pi}]]] but I'm not sure I undersand your problem. Commented Jul 14 at 12:17
• Maple 2024.1 give me solution : -8*Pi*Abs[Cos[2*x]] + 8*Pi. Commented Jul 14 at 12:32
• Thanks. That's an interesting point. What if the function is a complicated one, and I don’t know the specific values? Should I first solve the condition using Reduce to get the specific values and then use Integrate? I’m not sure how time-consuming this process will be. Commented Jul 14 at 13:29

To get rid of condition like If I use a trick:

G = LaplaceTransform[Integrate[InverseLaplaceTransform[
(a Sin[y/2]^2)/(b - c*Cos[y]), b, s], {y, -Pi, Pi}], s, b] /. {a -> 16 Sin[2 x]^2,
b -> 3 + Cos[4 x], c -> 2* Sin[2 x]^2}
G1 = FullSimplify[G, Assumptions -> {-Pi <= x <= Pi}] // Expand

(*8 π - 8 π Abs[Cos[2 x]]*)


another way:

F[x_, y_] := (16 Sin[2*x]^2 Sin[y/2]^2)/(3 + Cos[4*x] - 2 Cos[y] Sin[2*x]^2);
G2 = 2 Integrate[F[x, y], {y, 0, Pi}, Assumptions -> -Pi <= x <= Pi] // Expand

(*8 π - 4 π Abs[Sec[2 x]] - 4 π Abs[Sec[2 x]] Cos[4 x]*)

Limit[G2, x -> Pi/4] // Quiet(*Need a Limit to get a value!*)
(*8 π*)

• thank you very much! those are very useful tricks. out of curious, does LaplaceTransform and InverseLaplaceTransform works for arbitrary functions? Commented Jul 14 at 13:33
• @Xuemei It depends on the function and whether it is integrable by Integrate. Commented Jul 14 at 13:35
• oh, interesting. can you show an example which cannot be integrable by Integrate? thanks a lot! Commented Jul 14 at 13:48
• @Xuemei Example: Integrate[ InverseLaplaceTransform[(a Sin[y/2]^2)/(b - c*Cos[y]), c, s], {y, -Pi, Pi}]. Commented Jul 14 at 13:59