# An example from a Mathematica tutorial on integration returns a different answer from the tutorial

This page on "Integrals that Can and Cannot Be Done" suggests that, almost surprisingly, Mathematica can express the following integral in terms of elementary functions:

Integrate[Sqrt[Tan[x]], x]


However, that code currently returns the following:

2/3 Hypergeometric2F1[3/4, 1, 7/4, -Tan[x]^2] Tan[x]^(3/2)


which is totally different from what the tutorial says (both answers are correct, but the actual output is obviously not elementary).

Why does this happen? How can I get the form in terms of elementary functions?

The integration routines must have changed internally since the time that tutorial was written. However, you can still get the form shown in the tutorial, or something close to it, by reworking the output with FullSimplify and an appropriate complexity function that strongly penalizes results containing Hypergeometric2F1 terms:

Integrate[Sqrt[Tan[x]], x];
FullSimplify[%,
ComplexityFunction ->
(LeafCount[#] + 100 Count[#, _Hypergeometric2F1] + 10 Count[#, _Power] &)
]


The penalty for Power terms in the complexity function was introduced to get rid of an alternative expression containing a lot of square roots and ArcTanh terms.

Hypergeometric2F1 are like super special functions, they can be used to represent other elementary functions. Using FunctionExpand gives something closer to what shown on the help page

 Integrate[Sqrt[Tan[x]], x] // FunctionExpand // TraditionalForm


May be the help page used different version of Mathematica?

I am using V12.

Fyi, Rubi 4.16.1 gives similar result to what is shown on the help page

<< Rubi
res = Int[Sqrt[Tan[x]], x]
`

• Yes, I am also using v12. Interestingly, the answer on the tutorial page is similar to what Rubi gives. – Anixx Dec 25 '19 at 23:16
• @Anixx yes, answer looks similar to Rubi. Will add Rubi's answer also for completion. – Nasser Dec 25 '19 at 23:20