integral() not working properly?
7 次查看(过去 30 天)
显示 更早的评论
I am trying to integrate a function, however integral() doesn't seem to give the correct value -
f=@(t) sin(t.^3./3);
y=integral(f, 0, Inf)/pi
Doing symbolic integration
format long
syms x
z=double(int(sin(x^3/3), 0, Inf)/pi)
Doing the same in Wolfram Alpha results in the correct answer, I have attached the image file.
Any particular reason why this is happening?
0 个评论
回答(1 个)
Chunru
2022-7-15
编辑:Chunru
2022-7-15
% This is an oscillating function. It is difficult for numerical
% integration to converge (automatically compute intervals).
% Sometime, one can adjust Tol parameters and integration interval for luck.
f=@(t) sin(t.^3./3);
%y=integral(f, 0, Inf, 'RelTol', 0, 'AbsTol',1e-8)/pi
y=integral(f, 0, (10000*6*pi).^(1/3), 'RelTol', 0, 'AbsTol',1e-8)/pi
% The symbolic integration is evaluating the formula
format long
syms x
z=double(int(sin(x^3/3), 0, Inf)/pi)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!