# How to avoid complex terms in the results given by Integrate?

As shown by In1, integrating Sqrt[x^2 - 1]/(a + x^2) (1/x) returns a result with a complex terms; however, after I make a transformation as shown in In2, Mathematica gives a simpler form.

I have no doubt the two outputs are both right and are actually the same thing, but my question is: for the input as given in In1, is there any method that can be applied to the output of In1 that will give the same output as Out2? That is, can the result of In1 be transformed by Mathematica itself into the desired form, thus, making the integration easier?

In1:

Integrate[Sqrt[x^2 - 1]/(a + x^2) (1/x), {x, 1, t}, Assumptions -> t > 1 && a > 5]


In2:

Integrate[Sqrt[y - 1]/(a + y) (1/(2y)), {y, 1, t^2}, Assumptions -> t > 1 && a > 5]


• 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!
– user9660
Commented Jan 28, 2015 at 5:45
• Read theses closely related posts: Why does Integrate declare a convergent integral divergent? and Bug in mathematica analytic integration?. Commented Jan 28, 2015 at 11:24
• This is fixed now, before 13. Rubi's not needed anymore, same result even without it. Commented Dec 18, 2021 at 12:39

Mathematica is good in integration, but I think Rubi's Mathematica integration package produces more optimal results in general. See this for more examples.

In this case, Rubi produced the same result as your second integral (Rubi only does indefinite integration, but one can use limits to compute the definite integration (assuming it is valid to do so, i.e. the antiderivative that resulted is defined over the range on integration, etc..).

Compare the indefinite integration of your first example between Mathematica result and Rubi's

Clear[x, a];
r = Int[Sqrt[x^2 - 1]/(a + x^2) (1/x), x]


Clear[x, a];
r2 = Integrate[Sqrt[x^2 - 1]/(a + x^2) (1/x), x]


To evaluate the definite integral:

  sol = Limit[r, x -> t] - Limit[r, x -> 1]


Compare this to the result from your second example

Clear[y, a, t]
sol2 = Integrate[Sqrt[y-1]/(a + y)(1/(2 y)), {y, 1, t^2}, Assumptions -> t > 1 && a > 5];
Assuming[t > 1 && a > 5, Simplify[sol - sol2]]


I could not simplify Mathematica result to remove the complex result. Even using the assumptions you have.