필터 지우기
필터 지우기

why does the integral of sin(x) from -pi to 0 in matlab 2017b gives 0 instead of -2?

조회 수: 3 (최근 30일)
I'm trying to solve a simple integral but the software gives me a wrong answer. Please help me, I'm trying to calculate a lot of integrals but this problem doesn't let me to.
  댓글 수: 10
per isakson
per isakson 2018년 1월 13일
편집: per isakson 2018년 1월 13일
"I need it to work well" Thus contact Service Requests

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

답변 (1개)

Greg
Greg 2018년 1월 13일
편집: Greg 2018년 1월 13일
I would definitely submit this to tech support. I don't even need to recall my rusty calculus to know that the results should match in R2016b and R2017b (and I've confirmed as you all have that they don't...odd).
It does look like the desired value is returned in R2017b by:
vpaintegral(sin(x),x,-pi,0)
Not sure of all the differences between int and vpaintegral, though.
  댓글 수: 1
John D'Errico
John D'Errico 2018년 1월 13일
To me this feels like an error generated by the parser, but only TMW would know the true source of the error. It is definitely a bug and worth reporting as such. It might be a bugged special case inside int.
Interesting that SOME other intervals return a bug too. For example, if we add some positive integer multiple of 2*pi to the upper limit, it still returns 0.
syms x
int(sin(x),-pi,2*pi)
ans =
0
int(sin(x),-pi,12*pi)
ans =
0
(This still in R2017b.)
Surprisingly, this one does work:
int(sin(x),0,pi)
ans =
2
And it is not the fact that the lower limit was -pi.
int(sin(x),-pi,-2*pi)
ans =
-2
I tried a few similar cases, but cos(x) does not seem to bug out for any set of limits. I gave up quickly on cos though. It is also not the specific limits. so if you try a simpler kernel...
int(x,-pi,0)
ans =
-pi^2/2
There is no problem.
vpaintegral is a numerical integration tool, using a convergence tolerance. It should work much like the integral tool does, so an adaptive integration tool.

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by