# Why won't my integral evaluate?

Not sure why Mathematica won't integrate the definite or indefinite form of my function. I've tried the indefinite integral and it returns unevaluated. How can I see (and evaluate) what the actual integral looks like?

### Code

L[theta_] := Sqrt[(a*Sin[theta] - F)^2 + (b*Sin[theta])^2]

Integrate[L[theta], {theta, 0, Pi/2}]


This returns the unevaluated integral.

• Show the code you have tried, displayed in Mathematica format (not an image and not LaTeX). Otherwise, it is impossible for anyone to offer help. – bbgodfrey Jul 23 '17 at 20:46
• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) 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, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. – bbgodfrey Jul 23 '17 at 20:48
• You might write the integral here so that we see it. Otherwise, it is impossible to answer. – Alexei Boulbitch Jul 23 '17 at 20:48
• Does this edit work? – gummibear Jul 23 '17 at 20:58
• Can any conditions be specified for the constants? For instance, are they real? If so, are they positive? etc? – bbgodfrey Jul 23 '17 at 21:38

Maple was able to solve this directly

restart;
r:=int(sqrt((a*sin(theta) - F)^2 + (b*sin(theta))^2), theta=0..Pi/2) assuming positive;
r:=simplify(r);


But the result is large. You can compare this with the Mathematica result given above.

(4*((I*b+a)/((I*b+a)*F-a^2-b^2))^(1/2)*((I*b-a)*F+a^2+b^2)*a*
(-(I*F*b-F*a-a^2-b^2)/(I*F*b-F*a+a^2+b^2))^(1/2)*F*((I*b-a)/
((I*b-a)*F+a^2+b^2))^(1/2)*EllipticPi((-(I*F*b-F*a-a^2-b^2)/
(I*F*b-F*a+a^2+b^2))^(1/2), ((I*b-a)*F+a^2+b^2)/((I*b-a)*F-a^2-b^2),
((I*F*b+F*a+a^2+b^2)*(I*F*b-F*a+a^2+b^2)/((I*F*b+F*a-a^2-b^2)*
(I*F*b-F*a-a^2-b^2)))^(1/2))+((I*b-a)*F-a^2-b^2)*((I*b+a)/
((I*b+a)*F-a^2-b^2))^(1/2)*
(-(I*F*b-F*a-a^2-b^2)/(I*F*b-F*a+a^2+b^2))^(1/2)*(F^2-2*F*a+a^2+b^2)*
((I*b-a)/((I*b-a)*F+a^2+b^2))^(1/2)*EllipticE((-(I*b+a+F)/(-I*b+F-a))^(1/2),
((I*F*b+F*a+a^2+b^2)*(I*F*b-F*a+a^2+b^2)/((I*F*b+F*a-a^2-b^2)*
(I*F*b-F*a-a^2-b^2)))^(1/2))-2*(((I*b+a)/((I*b+a)*F-a^2-b^2))^(1/2)*
(-(I*F*b-F*a-a^2-b^2)/(I*F*b-F*a+a^2+b^2))^(1/2)*((I*b-a)*F^2+(I*b+a)*
(a^2+b^2))*((I*b-a)/((I*b-a)*F+a^2+b^2))^(1/2)*EllipticF((-(I*b+a+F)/
(-I*b+F-a))^(1/2), ((I*F*b+F*a+a^2+b^2)*(I*F*b-F*a+a^2+b^2)/
((I*F*b+F*a-a^2-b^2)*(I*F*b-F*a-a^2-b^2)))^(1/2))+(-((1/2)*I)*b+(1/2)*a)*
F+(1/2)*a^2+(1/2)*b^2)*F)/((I*b-a)*F-a^2-b^2)


$${\frac {1}{ \left( ib-a \right) F-{a}^{2}-{b}^{2}} \left( 4\,a\sqrt {{\frac {ib+a}{ \left( ib+a \right) F-{a}^{2}-{b}^{2}}}}F\sqrt {{\frac {ib-a}{ \left( ib-a \right) F+{a}^{2}+{b}^{2}}}}\sqrt {-{\frac {iFb-Fa-{a}^{2}-{b}^{2}}{iFb-Fa+{a}^{2}+{b}^{2}}}} \left( \left( ib-a \right) F+{a}^{2}+{b}^{2} \right) {\it EllipticPi} \left( \sqrt {-{\frac {iFb-Fa-{a}^{2}-{b}^{2}}{iFb-Fa+{a}^{2}+{b}^{2}}}},{\frac { \left( ib-a \right) F+{a}^{2}+{b}^{2}}{ \left( ib-a \right) F-{a}^{2}-{b}^{2}}},\sqrt {{\frac { \left( iFb+Fa+{a}^{2}+{b}^{2} \right) \left( iFb-Fa+{a}^{2}+{b}^{2} \right) }{ \left( iFb+Fa-{a}^{2}-{b}^{2} \right) \left( iFb-Fa-{a}^{2}-{b}^{2} \right) }}} \right) +\sqrt {{\frac {ib+a}{ \left( ib+a \right) F-{a}^{2}-{b}^{2}}}}\sqrt {{\frac {ib-a}{ \left( ib-a \right) F+{a}^{2}+{b}^{2}}}} \left( {F}^{2}-2\,Fa+{a}^{2}+{b}^{2} \right) \sqrt {-{\frac {iFb-Fa-{a}^{2}-{b}^{2}}{iFb-Fa+{a}^{2}+{b}^{2}}}} \left( \left( ib-a \right) F-{a}^{2}-{b}^{2} \right) {\it EllipticE} \left( \sqrt {-{\frac {ib+a+F}{-ib+F-a}}},\sqrt {{\frac { \left( iFb+Fa+{a}^{2}+{b}^{2} \right) \left( iFb-Fa+{a}^{2}+{b}^{2} \right) }{ \left( iFb+Fa-{a}^{2}-{b}^{2} \right) \left( iFb-Fa-{a}^{2}-{b}^{2} \right) }}} \right) -2\,F \left( \left( \left( ib-a \right) {F}^{2}+ \left( ib+a \right) \left( {a}^{2}+{b}^{2} \right) \right) \sqrt {{\frac {ib+a}{ \left( ib+a \right) F-{a}^{2}-{b}^{2}}}}\sqrt {{\frac {ib-a}{ \left( ib-a \right) F+{a}^{2}+{b}^{2}}}}\sqrt {-{\frac {iFb-Fa-{a}^{2}-{b}^{2}}{iFb-Fa+{a}^{2}+{b}^{2}}}}{\it EllipticF} \left( \sqrt {-{\frac {ib+a+F}{-ib+F-a}}},\sqrt {{\frac { \left( iFb+Fa+{a}^{2}+{b}^{2} \right) \left( iFb-Fa+{a}^{2}+{b}^{2} \right) }{ \left( iFb+Fa-{a}^{2}-{b}^{2} \right) \left( iFb-Fa-{a}^{2}-{b}^{2} \right) }}} \right) + \left( -i/2b+a/2 \right) F+1/2\,{a}^{2}+1/2\,{b}^{2} \right) \right) }$$

Update

    1.692081169+3.586206897*10^(-10)*I


• To what does this expression evaluate for a -> 2 /. b -> 1 /. F -> 1/2? Thanks. – bbgodfrey Jul 24 '17 at 5:48
• @bbgodfrey Maple says 1.692081169+3.586206897*10^(-10)*I, please see screen shot added. – Nasser Jul 24 '17 at 7:02
• And this is an actual result versus a Taylor or numerical approximation? – gummibear Jul 24 '17 at 18:48
• Does the I (capital i) stand for the imaginary number? – gummibear Jul 24 '17 at 18:48
• @gummibear yes. in Maple I means same as in Mathematica. Maple uses I to represent one of the square roots of -1, with -I representing the other, for computations over the complex numbers. – Nasser Jul 24 '17 at 18:53

Here is an answer, but you may not like it. Perform the indefinite integral and evaluate it at its endpoints:

s = Integrate[L[theta], theta]

ans = (s/.theta -> Pi/2) - (s/.theta -> 0)


The expressions are enormous. To be specific, LeafCount[s] is 17739. Root appears 317 times in s, but in all instances are solutions of,

F^2 - 4 a F x + (4 a^2 + 4 b^2 + 2 F^2) x^2 - 4 a F x^3 + F^2 x^4 == 0


ToRadicals simplifies s a bit, so that its LeafCount, while still enormous, is reduced to11644. Nonetheless, the result is correct. For instance,

N[ans/. a -> 2 /. b -> 1 /. F -> 1/2] // Chop
(* 1.69208 *)


which agrees with

NIntegrate[L[theta] /. a -> 2 /. b -> 1 /. F -> 1/2, {theta, 0, Pi/2}]


Due to the complexity of the symbolic solution, evaluating it numerically seems more practical.

FullSimplify is unable to simplify the expression, running for many hours without returning a result. However, the expression can be broken into pieces with Collect and other tools, allowing the expression to be simplified piecemeal to a LeafCount of about 4500, which still is very large. This simplified expression has three instances of EllipticPi, which probably can be combined by appropriate identities, thereby reducing the expression by another factor of two. Nonetheless, no simplification can be expected to produce a symbolic result that is convenient to analyze and manipulate. Hence, it still seems best to solve this integral numerically, which is fast and accurate.