3
votes

In MATLAB (R2017b, online version) I found an issue during symbolic integration: try to calculate integral of f(t) = abs(sin(t)) . Due to the fact that f(t) is always positive, I expect that the integral in [a, b] is lower equal than the integral in [a, b'] if b < b'. But:

int( abs(sin(t)), t, 0, pi )   -> 2 % OK
int( abs(sin(t)), t, 0, 2*pi ) -> 2 % NO (should be 4)

In fact, if we plot the function that represent the integral from 0 to x, which should be monotonic, we found something different:

% for each value x(i) of x we will calculate integral from 0 to x(i)
x = 0 : pi/8 : 4*pi;
% actual computation
Z = zeros(length(x), 1);                            % create array
syms t;                                             % create symbolic variable t
calculate_int = @(n) int(abs(sin(t)), t, 0, n);     % integral function
for i = 1 : length(Z)
    Z(i) = calculate_int(x(i));
end
% plot result
figure;
plot(x, Z);

results in this obviously non monotonic function:

Plot

Non symbolic integration gives no problem:

x = 0 : 0.01 : pi;
f = abs(sin(x));
value = sum(f * 0.01) % 2

x = 0 : 0.01 : 2 * pi;
f = abs(sin(x));
value = sum(f * 0.01) % 4
1
Are you sure you are running the code properly? Because I've tried your code and this is what I got: imgur.com/eqY2Wme - Tommaso Belluzzo
@TommasoBelluzzo: I can replicate this perfectly in the desktop version of R2017b. - horchler
This appears to be specific to R2017b. I cannot replicate the issue in R2017a and earlier. Seems like a bug. I suggest that you file a service request. - horchler
For my test I used 2017a <_< - Tommaso Belluzzo
So, to summarize, R2017b desktop has the issue, but < R2017a desktop does not. However, as noted by the OP, the R2017a online version has the bug. I cannot replicate this on desktop versions R2017a, R2016a, R2014a, R2010a. - Rody Oldenhuis

1 Answers

0
votes

It is a bug in Matlab R2017b. See @horchler comments for details.