Unexpected indefinite integration result

Consider following expression: $$\int_0^1 \sqrt{4194 x^4-6804 x^3+3960 x^2-972 x+90} \, dx$$

If i use N[] to calculate it, i get following result:

$$N\left[\int_0^1 \sqrt{4194 x^4-6804 x^3+3960 x^2-972 x+90} \, dx,25\right]$$

= 6.027972711543818613109397


If i use NIntegrate to calculate it, i get following result:

$$\text{NIntegrate}\left[\sqrt{4194 x^4-6804 x^3+3960 x^2-972 x+90},\{x,0,1\},\text{WorkingPrecision}\to 25\right]$$

= 6.027972711543818613109397


But if i try to calculate indefinite integral first, and then calculate the result i get following:

indefiniteIntegral[x_] = Integrate[Sqrt[4194 x^4 - 6804 x^3 + 3960 x^2 - 972 x + 90], x]


$$N[\text{indefiniteIntegral}[1]-\text{indefiniteIntegral}[0],25]$$

= 4.435757944345431340027424 + 0.042341350166508502449667i


Which is clearly different...

Am i missing something?

• Of definite relevance: Mathematica and the Fundamental Theorem of Calculus. The upshot is, don't use indefinite integrals to evaluate definite integrals in a compute algebra system unless you really know what you're doing. Even then, probably don't. Dec 13, 2022 at 21:51
• @march: Not a good advice if your goal is to find the exact solution - in that case never use numerical evaluation. Of course, it does not mean that it is always possible to express such a solution in finitely many functions. Dec 14, 2022 at 11:49
• The discontinuity of the antiderivative is a phenomenon noted in the Integrate reference page under Possible Issues > Indefinite Integrals Dec 14, 2022 at 16:34
• @azerbajdzan Unless there was a comment deleted, I see no advice regarding use of numeric integration. That stated, such use can be a viable way to check results. Dec 14, 2022 at 16:35
• @Daniel Lichtblau: How you interpret "don't use indefinite integrals to evaluate definite integrals in a compute algebra system"? So how would you evaluate definite integral if you cannot use indefinite integral and cannot use numeric evaluation? Dec 14, 2022 at 16:43

The integrand is continuous, but Mathematica's anti-derivative is not. This is why you can't use the anti-derivative to evaluate the definite integral between the limits.

integrand = Sqrt[4194 x^4 - 6804 x^3 + 3960 x^2 - 972 x + 90];
FunctionContinuous[integrand, x]


Plot[integrand, {x, 0, 1}]


But look at the anti-derivative

indefiniteIntegral[x_] =   Integrate[integrand], x];
ReImPlot [indefiniteIntegral[x], {x, 0, 1}]


Also

 FunctionContinuous[indefiniteIntegral[x], x]


Since your integrand is continuous at each point between $$x=0,x=1$$, then the anti-derivative should be differentiable at each one of these points as well there exists an antiderivative that is continuous between these points. The antiderivative given here does not have this property.

I identified the exact position of point of discontinuity to be (around 0.607405):

Root[-7 + 62 x - 162 x^2 + 122 x^3 + 13 x^4, 4]


So you can evaluate the integral in two parts: first from 0 to discontinuity point and second from discontinuity point to 1 like so:

int = Integrate[(4194 x^4 - 6804 x^3 + 3960 x^2 - 972 x + 90)^(1/2), x];
root = Root[-7 + 62 x - 162 x^2 + 122 x^3 + 13 x^4, 4];
(int /. x -> root - 10^-25) - (int /. x -> 0) + (int /.
x -> 1) - (int /. x -> root + 10^-25);
N[%, 25]

(* 6.027972711543818613109397 + 0.*10^-25 I *)


It is the exact same number you got by NIntegrate.

• Mmmm, brunch cut. Dec 13, 2022 at 21:51
• Not really. I think that is just bad antiderivative. Dec 14, 2022 at 3:48
• If you take the derivative, you get the original function back. Dec 14, 2022 at 9:25
• Not bad so much as occasionally naughty. Dec 15, 2022 at 0:23
• Nice analysis (and upvoted). Integrate does not manage to find this root (it times out in various attempts). If found, it is not clear that Limit would get the correct values approaching from opposite sides. I've seen at least one bug report where this in fact is the failure cause, in a case where Integrate did manage to locate the pach singularity for an antiderivative containing an elliptic. Dec 15, 2022 at 17:03