On Tue, 20 Nov 2007 10:42:48 -0800,
wrote:
> Instead of comparing sum to the "known" value of e**x, why not test for
> convergence? I.e., if sum == last_sum: break. Seems like that would be
> more robust (you don't need to know the answer to computer the answer),
> since it seems like it should converge.
That will only work if you know that the terms in your sequence are
monotonically decreasing: that is, if each term is smaller than the last.
It also assumes that the terms decrease reasonably rapidly, and you want
the full precision available in floats. Are you sure your algorithm is
that precise? It's one thing to produce 16 decimal places in your result,
but if only the first 12 of them are meaningful, and the last four are
inaccurate, you might as well not bother with the extra work.
--
Steven.