Numerical integral of sin(x)/x from 0 to inf
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Livvy Zhen
am 2 Dez. 2018
Kommentiert: Star Strider
am 2 Dez. 2018
I am using a loop to estimate the parameters in a formula. However, when using the syntax 'integral' to numerically integrate sin(x)/x from 0 to inf, Matlab always gives me a warning and a wrong answer. The exact result of this integral is pi/2 if I use the syntax 'int'. Unfortunately, for estimation purpose, numerical integration saves me a great deal of time, and I can only use 'integral' rather than 'int'. My formula is pretty similar to the problem of integrating sin(x)/x. Can anyone help me correct the result given by Matlab 'integral'? Many thanks!
0 Kommentare
Akzeptierte Antwort
Star Strider
am 2 Dez. 2018
One option is to use a large upper limit that is less than Inf:
z = integral(@(x) sin(x)./x, 0, 1E+4)
z =
1.57089154538596
That is reasonably close to
.
2 Kommentare
Star Strider
am 2 Dez. 2018
My pleasure.
Please post the function you want to integrate, as well as any additional information as necesary. It may be possible to use the 'Waypoints' name-value pair to help approximating it. With the necessary information, we may be able to help you with it.
Weitere Antworten (1)
madhan ravi
am 2 Dez. 2018
y=@(x)sin(x)./x
integral(y,0,inf)
5 Kommentare
madhan ravi
am 2 Dez. 2018
So the error message is really clear " it is difficult to approximate numerically"
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!