Search code examples
algorithmfloating-accuracynumerical-analysis

polynomial evaluation accuracy, multiplication versus division


let us say I have have polynomial in x, divided by a power of x:

p = (a + x(b + x(c + ..)))/(x**n)

efficiency aside, which would be more accurate computation numerically, the above or using division:

p = (((a/x + b)/x + c)/x + ...)

thanks


Solution

  • I think the difference is minimal, unless there is a chance that x**n overflows or underflows, in which case you should use the second expression.

    The two expressions differ in two places:

    1. The evaluation order is reversed (..., c, b, a) for the first expression and (a, b, c, ...) for the second expression. Which one is best depends on the value of the coefficients.
    2. The first expression has the .../x**n at the end. As Jonathan explains, for that reason it may be expected that the second expression is more accurate, because it has fewer operations. However, I think that the .../x**n causes only a minimal loss of accuracy (compared to other places where you lose accuracy), unless the x**n overflows or underflows.