Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

In order to compute the sum of a power series, we can use for loop, while loop or the analytic formula. I am wondering what is difference between those algorithms and how to improve the robustness of this question?

share|improve this question
Hi @Doudou, and welcome to Scicomp! Could you clarify what you mean by improving the robustness? –  Paul Feb 11 '13 at 14:32
@Doudou: maybe also what you mean by "the analytic formula"? Do you mean a closed form solution of an infinite series? –  GertVdE Feb 12 '13 at 12:54
One general comment: If you have a bunch of floating point numbers that you need to add together, add them in order from smallest to largest. Occasionally I've seen numeric analysts use a priority queue to ensure that the two smallest numbers are always added in any step. This minimises roundoff error. (Proof left as an exercise.) –  Pseudonym Feb 16 '13 at 21:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.