在MATLAB(R2017b,在线版)中,我在符号集成过程中发现了一个问题:尝试计算f(t) = abs(sin(t))
的积分。由于f(t)
总是正数,我希望[a, b]
中的积分低于[a, b']
中的积分b < b'
。但是:
int( abs(sin(t)), t, 0, pi ) -> 2 % OK
int( abs(sin(t)), t, 0, 2*pi ) -> 2 % NO (should be 4)
事实上,如果我们绘制代表从0
到x
的积分的函数,它应该是单调的,我们发现了不同的东西:
% 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);
导致这种明显的非单调功能:
非符号集成没有问题:
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
答案 0 :(得分:0)
这是Matlab R2017b中的一个错误。有关详细信息,请参阅@horchler注释。