Prev: Differential Equations
Next: figure sizing issue
From: James Tursa on 25 Jan 2010 21:44 "Kaze " <raicabogdan(a)gmail.com> wrote in message <hjjj5q$eg3$1(a)fred.mathworks.com>... > "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hjjf6e$8iu$1(a)fred.mathworks.com>... > > "Kaze " <raicabogdan(a)gmail.com> wrote in message <hji6h5$as3$1(a)fred.mathworks.com>... > > > > Hmmmm ... well, now isn't that curious? You got the same answer for the number of elements of F in the interval [1,2) as in the interval [1/64,1/32). Does that seem right to you? Is that what you expect, or would you expect to get a different answer for these two questions? > > > > > > > > James Tursa > > > > > > What I aspect is to understand what I'm doing and to have no errors. Of course the problem has to be solved corecly. > > > > > > I get the same answer but I don't think is wrong. > > > > Well, if you really think those results are correct then turn them in. Good luck. > > > > James Tursa > > Thank you. > > Regards. I would be interested in the answer that your professor has for #4. This question does not seem all that trivial to me. I can think of at least three ways of doing it (and have coded them up), but you either need some fancy code to generate the samples or make some assumptions about how the floating point processor behaves for different exponents to answer the question, neither of which I would expect a beginning student to understand. I am curious how your professor did it. James Tursa
From: Derek O'Connor on 26 Jan 2010 02:30 "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message > > I would be interested in the answer that your professor has for #4. This question does not seem all that trivial to me. I can think of at least three ways of doing it (and have coded them up), but you either need some fancy code to generate the samples or make some assumptions about how the floating point processor behaves for different exponents to answer the question, neither of which I would expect a beginning student to understand. I am curious how your professor did it. > > James Tursa This question is not trivial. Here is Prof Alan Edelman's answer (1994): http://www-math.mit.edu/%7Eedelman/homepage/papers/ieee.ps Derek O'Connor
From: Kaze on 26 Jan 2010 03:28 "Derek O'Connor" <derekroconnor(a)eircom.net> wrote in message <hjm5md$hi3$1(a)fred.mathworks.com>... > "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message > > > > I would be interested in the answer that your professor has for #4. This question does not seem all that trivial to me. I can think of at least three ways of doing it (and have coded them up), but you either need some fancy code to generate the samples or make some assumptions about how the floating point processor behaves for different exponents to answer the question, neither of which I would expect a beginning student to understand. I am curious how your professor did it. > > > > James Tursa > > This question is not trivial. Here is Prof Alan Edelman's answer (1994): > > http://www-math.mit.edu/%7Eedelman/homepage/papers/ieee.ps > > > Derek O'Connor Hello, He didn't show the last question to me. I was sure that I he would ask me why didn't I do the last questiong, but he only asked me about the first 3 and I was able to explain the functions typecast , realmax, realmin and why did I use them. Of course is thanks to you, you gave me a good explanation about the IEEE floating point without NaN and Inf. Because he needed to listen to others about their problems, it didn't took more than 5 minutes to evaluate me. Maybe next time, I will ask him how would he aswer to the last question, because as you probably know, I didn't do the last one. My problem was found by me today in a book of a Universty profesor in Romania, state Cluj. In his book, was my questions, if you are curiouse I can call or email the profesor and try to make him aswer the last question. Thank again.
From: James Tursa on 26 Jan 2010 04:00 "Derek O'Connor" <derekroconnor(a)eircom.net> wrote in message <hjm5md$hi3$1(a)fred.mathworks.com>... > "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message > > > > I would be interested in the answer that your professor has for #4. This question does not seem all that trivial to me. I can think of at least three ways of doing it (and have coded them up), but you either need some fancy code to generate the samples or make some assumptions about how the floating point processor behaves for different exponents to answer the question, neither of which I would expect a beginning student to understand. I am curious how your professor did it. > > > > James Tursa > > This question is not trivial. Here is Prof Alan Edelman's answer (1994): > > http://www-math.mit.edu/%7Eedelman/homepage/papers/ieee.ps > > > Derek O'Connor Don't have any s/w to open a ps file on the computer I am on at the moment. Will try at work tomorrow. A couple of my solutions were as follows: % 1st method % Direct method by generating random 64-bit integer bit patterns (as two % 32-bit pieces) and typecasting them as double precision bit patterns. x = uint32(floor(rand(n,1)*(2^32))); % Generate uniformly distributed 32-bit integers y = typecast(x,'double'); % Typecast them as IEEE double precision z = isnan(y) | isinf(y) | (y < realmin); % Figure out which ones are NaN, Inf, and denorm t = y(~z); % Get rid of the NaN, Inf, and denorm f = sum(t.*(1./t)==1) / numel(t); % Fraction of bit patterns satisfying the relationship disp(f); % 2nd method % Indirect method assumes that rand generates uniformly distributed bit patterns % down to the least significant bit after doing the +1 operation. Also assumes % that the floating point processor has the same rounding algorithm regardless % of the value of the exponent (probably a safe assumption, but still it is an % assumption). By looking only at the bit patterns for a fixed binary exponent % value (in this case the numbers between 1 and 2), we can extrapolate the % result for all exponent bit patterns (an assumption). x = rand(n,1)+1; % Generate uniformly distributed numbers in [1,2) f = sum(x.*(1./x)==1) / n; % Fraction of bit patterns satisfying the relationship disp(f); For critical work, I wouldn't rely on the 2nd method because of the assumptions made, but as it turns out for my PC the assumptions look to be correct since I get essentially the same answer as the first method which I trust to be uniformly distributed across F. The results for n=10000000: 0.84612180788734 % Method 1 0.84646010000000 % Method 2 I would hardly expect a beginning student to come up with this, which is why I was curious what the professor expected them to do. Thanks for the link ... hopefully I will be able to look at it tomorrow. James Tursa
From: James Tursa on 26 Jan 2010 13:04
"Derek O'Connor" <derekroconnor(a)eircom.net> wrote in message <hjm5md$hi3$1(a)fred.mathworks.com>... > > This question is not trivial. Here is Prof Alan Edelman's answer (1994): > > http://www-math.mit.edu/%7Eedelman/homepage/papers/ieee.ps Couldn't even open it in MS Visio, which is supposed to handle ps files. So haven't been able to look at this yet. James Tursa |