I have a question concerning 'result difference' - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

I have a question concerning 'result difference'

coolpursuitcoolpursuit Posts: 1Member
I'm College student, and now studying Matlab.

I saw a verification problem. problem is following...

EXAMPLE
Let x(n) be a random sequence uniformly distributed between [0,1] over 0> x = rand(1,11); n=0:10;
>> k = 0:500; w = (pi/500)*k;
>> X = x * (exp(-j*pi/500)).^(n'*k); % DTFT of x
>>
>> y = x; m = n+2;
>> Y = y * (exp(-j*pi/500)).^(m'*k); % DTFT of y
>>
>> % verification
>> Y_check = (exp(-j*2).^w).*X;
>> error = max(abs(Y-Y_check)); % difference
error =
5.77e-015

My question is that,
1) What is the reason that error is NOT zero?
error is very very marginal value, but I think, that error must be zero in digital calculation(like MATLAB)
Could you tell me the reason?

2) and, if there is way that error be zero, Could you teach me about that?

Before that EXAMPLE, I think that all digital calculation has same result.
for example, 1 + 2 + 3 = 6
Anytime, and by any computer, 1 + 2 + 3 = 6.

I really really want to know about that.

Please someone answer my question...

Comments

  • jjasso5jjasso5 Posts: 41Member
    Digital calculators and computers have limitations in accuracy.
    They are working with a limited number of bits and bytes, and that
    creates a problem...

    You're not working with continuous values but with discrete ones, and
    you'll loose the information in between those discrete values.

    For example, calculate this simple operation, manually and with Matlab
    3*(4/3 - 1) - 1

    What did you expect?
    =)

Sign In or Register to comment.