[18335fall09] pset 2 clarifications

Steven G. Johnson stevenj.mit at gmail.com
Wed Sep 30 13:17:44 EDT 2009


Hi gang,

Regarding problem 3(d), in the file div2sum.m, one of you asked  
whether the line:

         s = single(div2sum(x(1:floor(n/2))) + div2sum(x(floor(n/ 
2)+1:n)));

should really be:

         s = single(single(div2sum(x(1:floor(n/2)))) +  
single(div2sum(x(floor(n/2)+1:n))));

i.e. shouldn't we round and then add and then round to do the addition  
in single precision, rather than adding and then rounding?  The answer  
is yes, in principle, but in practice I don't think it makes any  
significant difference.  You use either of the versions above if you  
want.

Regarding problem 4(a), Trefethen exercise 15.1 parts (e) and (f),  
where you are computing e by the Taylor series for exp(x), some of you  
asked how you can compute 1/k! without using division.  I don't think  
that is the intention of the problem -- the point is what is the  
impact of doing the sum from left to right or from right to left.   
Instead, just assume that you can compute 1/k! to O(machine epsilon)  
relative error (which is true in practice by a variety of techniques),  
and focus on how the rounding errors accumulate when you do the sum.

--SGJ



More information about the 18335fall09 mailing list