6
$\begingroup$

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?

$\endgroup$
9
$\begingroup$

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] &)
]

result of simplification

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.

$\endgroup$
6
$\begingroup$

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

Mathematica graphics

May be the help page used different version of Mathematica?

Mathematica graphics

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]

Mathematica graphics

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.