2
$\begingroup$

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?

$\endgroup$
  • 2
    $\begingroup$ Hi @Doudou, and welcome to Scicomp! Could you clarify what you mean by improving the robustness? $\endgroup$ – Paul Feb 11 '13 at 14:32
  • 2
    $\begingroup$ @Doudou: maybe also what you mean by "the analytic formula"? Do you mean a closed form solution of an infinite series? $\endgroup$ – GertVdE Feb 12 '13 at 12:54
  • 3
    $\begingroup$ 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.) $\endgroup$ – Pseudonym Feb 16 '13 at 21:46