# Getting long complex-valued integrals when simpler real-valued expressions exist

I have a long list of real-valued functions I'd like to integrate symbolically. For many of them, Mathematica gives me results with long complex-valued expressions involving weird functions such as EllipticF, even though I know that if I first manually apply a simple substitution such as $u=\sin\theta$ or $u=\cos\theta$, I will get a simple elementary real-valued expression.

As an example, I want to integrate $\arcsin(a/\sin\theta)\cdot\cos\theta$ for some constant $a$ which satisfies $0<a<\sin\theta$ throughout the integration domain. Now, Integrate[ArcSin[a/ Sin[theta]] Cos[theta], theta, Assumptions -> 0<a<Sin[theta]] gives the result

$$\sin (\theta ) \sin ^{-1}(a \csc (\theta ))+\frac{i a \cot \left(\frac{\theta }{2}\right) \sqrt{1-\frac{a^2 \tan ^2\left(\frac{\theta }{2}\right)}{-a^2+2 \sqrt{1-a^2}+2}} \sqrt{\frac{a^2 \tan ^2\left(\frac{\theta }{2}\right)}{a^2+2 \sqrt{1-a^2}-2}+1} \left(F\left(i \sinh ^{-1}\left(\sqrt{\frac{a^2}{a^2+2 \sqrt{1-a^2}-2}} \tan \left(\frac{\theta }{2}\right)\right)|-\frac{a^2+2 \sqrt{1-a^2}-2}{-a^2+2 \sqrt{1-a^2}+2}\right)-2 \Pi \left(\frac{a^2+2 \sqrt{1-a^2}-2}{a^2};i \sinh ^{-1}\left(\sqrt{\frac{a^2}{a^2+2 \sqrt{1-a^2}-2}} \tan \left(\frac{\theta }{2}\right)\right)|-\frac{a^2+2 \sqrt{1-a^2}-2}{-a^2+2 \sqrt{1-a^2}+2}\right)\right)}{\sqrt{\frac{a^2}{a^2+2 \sqrt{1-a^2}-2}} \sqrt{\frac{2 a^2+\cos (2 \theta )-1}{\cos (2 \theta )-1}}},$$ where $F=$ EllipticF and $\Pi=$ EllipticPi, but if I first perform the subsitution $u=\sin\theta$ and then evalute Integrate[ArcSin[a/u] , u] /. u -> Sin[theta], I get the much simpler

$$\frac{a \csc (\theta ) \sqrt{\sin ^2(\theta )-a^2} \log \left(\sqrt{\sin ^2(\theta )-a^2}+\sin (\theta )\right)}{\sqrt{1-a^2 \csc ^2(\theta )}}+\sin (\theta ) \sin ^{-1}(a \csc (\theta )).$$

How do I make Mathematica give me the second result without explicitly performing the variable substitution? In my case, all my functions are of the form $\cos\theta\cdot f(\sin\theta)$ or of the form $\sin\theta \cdot f(\sin^2(\theta))$ or of a form which does not need any special substitution (but my list of functions is too long for me to group them according to this). Can I encourage Mathematica to try the substitutions $u=\cos\theta$ and $u=\sin\theta$ first, or can I convince Mathematica that everything is real-valued and not to worry about subtleties concerning complex-valued functions?

• Here is a quite similar problem: Why does Integrate declare a convergent integral divergent?. – Artes Aug 18 '14 at 17:18
• The condition 0<a<Sin[theta] with the statement that ais a constant sounds strange. – Alexei Boulbitch Aug 19 '14 at 7:26
• @AlexeiBoulbitch: I agree, but I don't know how else to communicate it to Mathematica. I've tried simply assuming a>0, which made no difference, and I'm not getting any errors assuming also a<Sin[theta] so I left it in there. – user19228 Aug 19 '14 at 12:24
• @user19228 I see. I tried your integral and saw that this condition makes no harm (and no action at all). In fact this condition is natural to use in Simplify or FullSimplify, which you might apply to the result of the integration, rather than in the Integrate. – Alexei Boulbitch Aug 20 '14 at 12:47