# Symbolic integration conditional bug?

I just ran across this:

Assuming[x > 0, Integrate[1/t^2, {t, 1, x}]]


gives the output

ConditionalExpression[(-1 + x)/x, x > 1]


which is clearly too restricted. The correct conditional should be x>0.

The result doesn't evaluate at x=1/2, but

Integrate[ 1/t^2, {t, 1, 1/2} ]


correctly evaluates to -1.

Any thoughts for a workaround?

I'm on OSX with Mathematica 9.0.1.0.

EDIT:

The result cannot be explained by Mathematica having a strong requirement of the upper boundary being strictly greater than the lower boundary of the integral. This can be seen when integrating over functions without singularity or by moving the singularity but not the lower boundary. In this case the conditional is also shifted, despite the unchanged lower boundary.

So there must be some (unintented) interaction between mixed constant and variable boundaries and singularities.

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 Nov 26 '14 at 14:30
• GenerateConditions -> False? – Michael E2 Nov 26 '14 at 14:30
• Well, yes, but I'd actually appreciate having correct conditionals :). Thank you for the suggestion! – Jazzmaniac Nov 26 '14 at 14:31
• but when writing Assuming[x > 0, Integrate[1/t^2, {t, 1, x}]], then in here 1 is min, and x is max. According to help. Hence x has to be greater than 1. In the second example, when you wrote Integrate[ 1/t^2, {t, 1, 1/2} ] here you are giving numerical values for the limits, so it knows that the upper limit is less than the lower limit? – Nasser Nov 26 '14 at 14:32
• I wasn't sure what sort of workaround you sought, an expression that would evaluate or a precise, correct result. – Michael E2 Nov 26 '14 at 14:33

community wiki, not an answer, just some hints, too small for comment:

Integrate[1/t^2, {t, 1, x}]


May be some smart math person can decode the above. Now:

Assuming[Element[x, Reals], Integrate[1/t^2, {t, 1, x}]]


So the x>1 condition comes out just from say x is real. fyi, This is how Maple does it:

int(1/t^2, t=1..x) ;


It does not even integrate this, it says:

However,

 int(1/t^2, t=1..x) assuming x>0 ;


gives same as Mathematica:

But Maple does not generate answers with conditionals like Mathematica. User must give the conditions. So the above is for x>0. But using AllSolutions will make it generate this

 int(1/t^2, t=1..x,AllSolutions )  ;


The above seems to be the answer the OP is expecting to get from Mathematica.

First, Integrate normally takes the assumptions as given and only adds conditions that are needed beyond the assumptions specified. Thus I would expected the integral

Assuming[x > 0, Integrate[1/t^2, {t, 1, x}]]


to result in

1 - 1/x


instead of a ConditionalExpression, since the assumption x > 0 is sufficient to guarantee the result is valid.

The integral by itself produces a (somewhat) correct result:

int = Integrate[1/t^2, {t, 1, x}]
(*
ConditionalExpression[
1 - 1/x, ((Re[1/(-1 + x)] >= 0 ||
Re[1/(-1 + x)] <= -1) && (x ∉ Reals ||
Re[1/(-1 + x)] < -1 || Re[x] >= 1)) ||
1/(-1 + x) ∉ Reals]
*)


It evaluates correctly but in two cases produces messages at x -> 0 and x -> 1:

Table[int, {x, {-1, 1/2, 2}}]
(*
{Undefined, -1, 1/2}
*)

int /. x -> 0
(* Power::infy: Infinite expression 1/0 encountered. >> *)
(*
Undefined
*)

int /. x -> 1
(* Power::infy: Infinite expression 1/0 encountered. >> (several) *)
(*
0
*)


But there's something funny going at with x -> 1. The condition 1/(-1 + x) ∉ Reals evaluates to True for x -> 1, and therefore the integral expression is valid. But some functions take the expression 1/(-1 + x) in the condition to impose a restriction on x, that x ≠ 1. For instance

MapAt[
Reduce[# && x > 0] &,
Integrate[1/t^2, {t, 1, x}],
2]
(*
ConditionalExpression[1 - 1/x, 0 < x < 1 || x > 1]
*)


This may have something to do with the result of the OP's integral.

Finally, another way to get a correct result is to give the integral a good whack and knock it off the real line:

Assuming[x > 0, Integrate[1/t^2, {t, 1, I, x}]]
(*
1 - 1/x
*)


Please consider this just as a comment. It seems you should explicitly say to integrate that you want work with 'say' inversed boundaries, because only then it understands it:

Integrate[1/t^2, {t, 1, x}, Assumptions -> x < 1]


ConditionalExpression[(-1 + x)/x, x > 0]

I suppose it rather some kind of reticence. As a workaround I could suggest one can work this way:

x1 = 1;
xlowlimit = 0;

fun[t_] := -1/t^2;

If[x1 < xlowlimit ,
Assuming[x > x1reg, Integrate[fun[t], {t, x1, x}]],
{ConditionalExpression[
Assuming[xlowlimit < x < x1, Integrate[fun[t], {t, x1, x}]], x1reg < x < x1],
Assuming[xlowlimit < x, Integrate[fun[t], {t, x1, x}]]}]