Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to compute

Integrate[Sqrt[x^4 + (y - y^2)^2], {x, 0, y}]

Mathematica 8 gives

(* ConditionalExpression[y^2 Abs[-1 + y]
                         Hypergeometric2F1[-(1/2), 1/4, 5/4, -(y^2/(-1 + y)^2)],
                         0 < y < 1 || y > 1] *)

but it is perfectly well defined for $y=1$ where the answer is exactly $1/3$. Is this a bug?

share|improve this question
It is not a bug. At the point y=1, you have a 0 * ∞ indeterminacy. When you take a limit y -> 1, you recover that result you mention, but you have to take that limit, and Mathematica is IMO correct to draw your attention to it, since it is not possible for it to see whether or not the function is well-defined at that point without some further analysis, which was not requested. – Leonid Shifrin Apr 15 '13 at 19:02
It is not a bug, but on the other hand it could automatically find its value also at y==1. Nevertheless you can do it simply with assumption : Integrate[Sqrt[x^4 + (y - y^2)^2], {x, 0, y}, Assumptions -> y == 1] yields $\frac{1}{3}$. – Artes Apr 15 '13 at 19:06
@LeonidShifrin I don't understand. Integrate[Sqrt[x^4 + (1 - 1^2)^2], {x, 0, 1}] = 1/3. You don't need to take limits. – Anush Apr 15 '13 at 19:07
Perhaps, I made too strong a statement. I meant to say that the way Mathematica computes integrals, it may miss some points of measure 0. Saying that this is a bug is one way to look at it, but I prefer to take a (arguably more constructive) view on it, namely that we are still far from complete automation, and have to take into account such peculiarities. – Leonid Shifrin Apr 15 '13 at 19:10
@LeonidShifrin That makes sense. Is it worth reporting them or do Wolfram actively search out such things? – Anush Apr 15 '13 at 19:12
up vote 4 down vote accepted

From here:

The overall goal of symbolic computation is typically to get formulas that are valid for many possible values of the variables that appear in them. It is however often not practical to try to get formulas that are valid for absolutely every possible value of each variable.


The basic operations of Mathematica are nevertheless carefully set up so that whenever possible the results obtained will be valid for almost all values of each variable.

So, congratulations; the solution Mathematica got for you happens to be indeterminate at the particular argument you are interested in. Nevertheless, taking limits yields the result you seem to expect:

Limit[y^2 (y - 1) Hypergeometric2F1[-(1/2), 1/4, 5/4, -(y/(y - 1))^2],
      y -> 1] // FullSimplify

Since Mathematica doesn't know everything (GASP!), any result it gives will sometimes need further massage before you obtain a more practical form. In this case, we apply one of the Euler transformations of the Gaussian hypergeometric function to give a form that seems more suited to your needs:

anush[y_] :=
          y^2 Sqrt[1 + 2 y (y - 1)] Hypergeometric2F1[-1/2, 1, 5/4, y^2/(1 + 2 y (y - 1))]


anush[1] // FullSimplify

Compare with the original integral:

With[{y = 9/10}, {NIntegrate[Sqrt[x^4 + (y - y^2)^2], {x, 0, y}, WorkingPrecision -> 20], 
                  N[anush[y], 20]}]
   {0.27187611249376847527, 0.27187611249376847433}

Close enough for me!

It should be noted that the particular solution I gave gives the same results as the integral only over $[0,\infty)$; if you're evaluating for negative y, then you will have to do some sign-flipping on your own.

FWIW, what you have there is what's called an elliptic integral, since you have the square root of a quartic polynomial present. The general form of your particular integral will involve the incomplete elliptic integrals of the first and second kinds (EllipticF[] and EllipticE[] in Mathematica, respectively). I don't think much of Mathematica's symbolic capabilities with respect to elliptic integrals, so I'd give you the advice to look at a book like Byrd/Friedman (in particular, see section 260 onwards) if you really, truly, genuinely need the expression in terms of elliptic integrals.

share|improve this answer
Thanks. I suppose I have very (unreasonably?) high expectations of Mathematica given how mature it is relative to what I might have expected from versions 1-5, say. In particular, given that it can perform the integral at $y=1$ perfectly I wonder why it isn't a good idea for it to try to before it returns the incomplete answer. So I suppose my complaint is that it actually knows how to provide a complete solution but doesn't. – Anush Apr 16 '13 at 7:28
@Anush, from what I've seen, definite numeric arguments are handled rather differently from generic parameters; it is then not too surprising that the result you get from specific numerical parameters may be something completely different from what you get if only generic parameters are there. You might by the way want to look at the Assuming[] function, which does allow some level of control. – J. M. Apr 16 '13 at 9:51
Has there been any improvement in how Mathematica handles symbolic elliptic integrals since this answer was published? Manipulating elliptic integrals as above is tedious albeit straightforward, so a useful workaround (besides using direct numeric arguments) would be nice... – Semiclassical Mar 2 '15 at 3:17
@Semiclassical, unless they've gotten around to handling elliptic integrals through the Carlson route, I'd doubt there's been any improvement. – J. M. May 1 '15 at 19:28

You can suppress the generation of conditional expressions:

Integrate[Sqrt[x^4 + (y - y^2)^2], {x, 0, y}, GenerateConditions -> False]
(* V9.0.1 (Sqrt[(-1 + y)^2 y^2] Hypergeometric2F1[-(1/2), 1/4, 5/4, -(y^2/(-1 + y)^2)])/(1/y^4)^(1/4) *)
(* V8.0.4 (y^3 (1 + 2 (-1 + y) y - 2 (-1 + y)^3 Sqrt[I/((-1 + y) y)] Sqrt[(1 + 2 (-1 + y) y)/(-1 + y)^2]
          EllipticF[I ArcSinh[Sqrt[I/((-1 + y) y)] y], -1]))/(3 Sqrt[y^2 (1 + 2 (-1 + y) y)]) *)

You can simplify the V9.0.1 result if, say, y is known to be real:

 (Sqrt[(-1 + y)^2 y^2] Hypergeometric2F1[-(1/2), 1/4, 5/4, -(y^2/(-1 + y)^2)])/(1/y^4)^(1/4),
 Element[y, Reals]]
(* y^2 Abs[-1 + y] Hypergeometric2F1[-(1/2), 1/4, 5/4, -(y^2/(-1 + y)^2)] *)

The V8.0.4 result does not simplify appreciably. In any of these forms, there is a removable discontinuity at y == 1. There is (probably) no way to remove the discontinuity with algebraic simplification, but you can take the limit, as Leonid commented, to find the value at 1.

I do not think this is a bug. In expressing answers in terms of commonly known functions, removable discontinuities are sometimes inevitable. (Sin[x]/x is the classic example from first-year calculus.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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