Why the difference? (Length of curve)

Trying to find the length of a curve

gx = x^3 - 9 x;

in the interval 0<=x<=3

Wondering why Mathematica produces the following different results:

gx = x^3 - 9 x;
Plot[gx, {x, 0, 3}]
Integrate[Sqrt[1 + (D[gx, x])^2], {x, 0, 3}] // N
NIntegrate[Sqrt[1 + (D[gx, x])^2], {x, 0, 3}]

-0.0633531 + 0.150976 I
21.1806

HI Todor,

I cannot reproduce that.

Could you provide some more information, e.g. which version and OS you are using?

Best wishes,
Marco

In addition, if you use the version 10 or higher, you can use the new ArcLength command:

ArcLength[{x, x^3 - 9 x}, {x, 0, 3.0}]

for easier input, and works in all dimensions and can also work in different coordinate systems.

I can also not recreate your complex output (version 10.3 on OSX El Capitan).

Thanks for the reply

$Version
"10.0 for Linux x86 (64-bit) (June 29, 2014)"

I also tried it on a x64 ver 9 Mathematica under Win 7 x64 with the same results

/don’t remember the exact ver and have no access to that machine at the moment/

Have you tried running the 4 lines on a fresh new kernel? If that still gives you the complex result, you should consider sending a bug report.

As a habit anytime I start getting unexpected results I completely shutdown Mathematica and start a fresh session

Quite often the culprit turns out to be some leftover variables from previous computations

This is not the case here though. As for the bug report - I kinda know what the response is going to be - “Update to the latest version”

Thanks for you input once again