integral() not working properly?
14 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Chunru
on 15 Jul 2022
Edited: Chunru
on 15 Jul 2022
% 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)
See Also
Categories
Find more on Number Theory in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!