Numerical integral of sin(x)/x from 0 to inf

조회 수: 11 (최근 30일)
Livvy Zhen
Livvy Zhen 2018년 12월 2일
댓글: Star Strider 2018년 12월 2일
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!

채택된 답변

Star Strider
Star Strider 2018년 12월 2일
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
Livvy Zhen
Livvy Zhen 2018년 12월 2일
Thanks! I have tried that before. But this function is just for demonstration. My formula is similar to it and this setup will greatly slow down my estimation. I am wondering if Matlab could use a more robust way to calculate the numerical integral.
Star Strider
Star Strider 2018년 12월 2일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

madhan ravi
madhan ravi 2018년 12월 2일
y=@(x)sin(x)./x
integral(y,0,inf)
  댓글 수: 5
madhan ravi
madhan ravi 2018년 12월 2일
So the error message is really clear " it is difficult to approximate numerically"
Livvy Zhen
Livvy Zhen 2018년 12월 2일
That is why I am posting this question. This numerical integral works well on other softwares.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by