integral() not working properly?
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Chunru
le 15 Juil 2022
Modifié(e) : Chunru
le 15 Juil 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)
1 commentaire
Voir également
Catégories
En savoir plus sur Number Theory dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!