MATLAB: Do I receive incorrect results in Symbolic Toolbox 3.1.5 (R2007a) when evaluating an indefinite integral over bounds with floating-point precision

Symbolic Math Toolbox

I execute the following code:
syms x
f=2/3*x*(8-x^4)^(3/2);
I=double(int(f,0,2^(3/4)));
This function is defined over [-2^(3/4), 2^(3/4)] and is positive.
The result should be 4*pi.
But I returns:
I =
-12.566370614359172 - 0.000000000000000i

Best Answer

This is a floating-point precision issue.
The rational power 2^(3/4) is evaluated at double precision and that is slightly larger than 2^(3/4). Also, in double precision 2^(3/4) is slightly larger than true 2^(3/4), therefore the integral starts involving complex numbers and branch cuts. This is why, once you cross the branch cut, the answer becomes complex and adds multiples of the winding number.
To work around this issue, you should use fractional symbolic values for the limits of integration. This will allow you to use the infinite precision capabilities of Maple.
The code should be rewritten as follows:
I=int(f,0,sym('2^(3/4)'))
This returns the expected result:
I =
4*pi
Related Question