4
$\begingroup$

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?

$\endgroup$
19
  • 2
    $\begingroup$ 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. $\endgroup$
    – march
    Dec 13, 2022 at 21:51
  • $\begingroup$ @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. $\endgroup$ Dec 14, 2022 at 11:49
  • $\begingroup$ The discontinuity of the antiderivative is a phenomenon noted in the Integrate reference page under Possible Issues > Indefinite Integrals $\endgroup$ Dec 14, 2022 at 16:34
  • $\begingroup$ @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. $\endgroup$ Dec 14, 2022 at 16:35
  • $\begingroup$ @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? $\endgroup$ Dec 14, 2022 at 16:43

2 Answers 2

7
$\begingroup$

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]

Mathematica graphics

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

Mathematica graphics

But look at the anti-derivative

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

Mathematica graphics

Also

 FunctionContinuous[indefiniteIntegral[x], x]

Mathematica graphics

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.

$\endgroup$
0
6
$\begingroup$

Read EllipticPi about its branch cut discontinuities in "Details" section.

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.

$\endgroup$
5
  • 1
    $\begingroup$ Mmmm, brunch cut. $\endgroup$
    – march
    Dec 13, 2022 at 21:51
  • $\begingroup$ Not really. I think that is just bad antiderivative. $\endgroup$ Dec 14, 2022 at 3:48
  • 2
    $\begingroup$ If you take the derivative, you get the original function back. $\endgroup$ Dec 14, 2022 at 9:25
  • $\begingroup$ Not bad so much as occasionally naughty. $\endgroup$ Dec 15, 2022 at 0:23
  • $\begingroup$ 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. $\endgroup$ Dec 15, 2022 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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