필터 지우기
필터 지우기

Why dont matlab answers match theoretically calculated answers?

조회 수: 2 (최근 30일)
HAMZA Butt
HAMZA Butt 2016년 5월 5일
댓글: HAMZA Butt 2016년 5월 7일
Hi,
Ive been asked to explain why the answers I obtain from MATLAB of the step and impulse response is different from the mathematical equations/solutions. Any ideas why there is a difference??

채택된 답변

Walter Roberson
Walter Roberson 2016년 5월 5일
MATLAB does not use infinite precision like theoretical calculations do.
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 5월 5일
As a quick example:
Suppose you add 1/1 + 1/2 + 1/3 + 1/4 + 1/5 and so on, using double precision arithmetic. You reach 10^16 and you add it in. And then every result beyond that is less than 1/10^16 and so adding it on cannot have any effect on double precision numbers that exceed one, since the smallest difference between adjacent representable double precision numbers is about 1E-16. You could keep going as long as you liked, but each additional entry would add a value too small to alter the floating point sum. From this you deduce that the sum of 1/N for N = 1 to infinity must be the sum you have reached -- because additional terms cannot change the value.
But the sum of 1/x is something you might recognize from calculus: sum(1/x) is like integral(1/x) from 1 to x, and integral(1/x) from 1 is ln(x) . So by adding double precision values and seeing that the sum cannot change and deciding that we are done, we are implicitly declaring that ln(x) for x > 10^16 is the same as ln(10^16), since the sum cannot change with the small additions. But! we know that ln(infinity) is infinity: somehow all of those 1/x contributions past what double precision can represent, add up to infinity.
You can make these kinds of calculations in theory and get exact answers, but once you start making the calculations in practice, you need to be very careful. Such as doing the sum from the smaller terms towards the larger ones so that the smaller terms have a chance to accumulate without being overwhelmed by the 1E-16 finite precision if you started from larger terms to smaller.
HAMZA Butt
HAMZA Butt 2016년 5월 7일
appreciate the example Walter
thanks

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

추가 답변 (0개)

카테고리

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