Numerical integral of sin(x)/x from 0 to inf
Show older comments
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!
Accepted Answer
More Answers (1)
madhan ravi
on 2 Dec 2018
y=@(x)sin(x)./x
integral(y,0,inf)
5 Comments
Livvy Zhen
on 2 Dec 2018
madhan ravi
on 2 Dec 2018
Edited: madhan ravi
on 2 Dec 2018
what error are you getting? Below is the warning I got
Warning: Reached the limit on the maximum number of intervals in use.
Approximate bound on error is 4.9e+00. The integral may not exist, or it may
be difficult to approximate numerically to the requested accuracy.
> In integralCalc/iterateScalarValued (line 372)
In integralCalc/vadapt (line 132)
In integralCalc (line 83)
In integral (line 88)
Livvy Zhen
on 2 Dec 2018
Edited: Livvy Zhen
on 2 Dec 2018
madhan ravi
on 2 Dec 2018
So the error message is really clear " it is difficult to approximate numerically"
Livvy Zhen
on 2 Dec 2018
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!