/** * Returns the result of evaluating a univariate polynomial using * Horner's method in double precision floating point arithmetic. * * * see [Horner's Method](https://en.wikipedia.org/wiki/Horner%27s_method) * * * the worst-case forward error bound for Horner's method is explicitly given * by: |P(x) - P̂(x)| ≤ (2d·u / (1-2d·u)) ∑ᵢ₌₀ⁿ |aᵢ| |x|ⁱ, i.e. * by: |P(x) - P̂(x)| ≤ γ(2d) ∑ᵢ₌₀ⁿ |aᵢ| |x|ⁱ where d is the degree of the polynomial * * @param p a polynomial with coefficients given densely as an array of double * floating point numbers from highest to lowest power, e.g. `[5,-3,0]` * represents the polynomial `5x^2 - 3x` * @param x the value at which to evaluate the polynomial * * @doc */ function Horner(p: number[], x: number): number { let q = 0; for (let i=0; i