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?


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

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

This returns the unevaluated integral.

  • $\begingroup$ 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. $\endgroup$ – bbgodfrey Jul 23 '17 at 20:46
  • $\begingroup$ 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. $\endgroup$ – bbgodfrey Jul 23 '17 at 20:48
  • $\begingroup$ You might write the integral here so that we see it. Otherwise, it is impossible to answer. $\endgroup$ – Alexei Boulbitch Jul 23 '17 at 20:48
  • $\begingroup$ Does this edit work? $\endgroup$ – gummibear Jul 23 '17 at 20:58
  • $\begingroup$ Can any conditions be specified for the constants? For instance, are they real? If so, are they positive? etc? $\endgroup$ – bbgodfrey Jul 23 '17 at 21:38

Maple was able to solve this directly

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

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

 (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*b+F-a))^(1/2), ((I*F*b+F*a+a^2+b^2)*(I*F*b-F*a+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) } $$


To answer comment:


Mathematica graphics

  • $\begingroup$ To what does this expression evaluate for a -> 2 /. b -> 1 /. F -> 1/2? Thanks. $\endgroup$ – bbgodfrey Jul 24 '17 at 5:48
  • $\begingroup$ @bbgodfrey Maple says 1.692081169+3.586206897*10^(-10)*I, please see screen shot added. $\endgroup$ – Nasser Jul 24 '17 at 7:02
  • 1
    $\begingroup$ And this is an actual result versus a Taylor or numerical approximation? $\endgroup$ – gummibear Jul 24 '17 at 18:48
  • $\begingroup$ Does the I (capital i) stand for the imaginary number? $\endgroup$ – gummibear Jul 24 '17 at 18:48
  • $\begingroup$ @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. $\endgroup$ – 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.

  • $\begingroup$ They are enormous. What does the # symbol mean in the resulting expression? How can I assign values to a,b and F after I get the enormous expression? Thank you. $\endgroup$ – gummibear Jul 23 '17 at 21:56
  • $\begingroup$ Look up the documentation for Root. I can provide more detail and perhaps a simpler solution when I have more time, probably in about four hours. $\endgroup$ – bbgodfrey Jul 23 '17 at 22:01

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.