const { abs } = Math; /** * * used in algorithms within [2] below, see e.g. eq. (7) and (8) in that paper. * * * @param p1 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 p2 another polynomial * * * see [[1] Algorithms for Accurate, Validated and Fast Polynomial Evaluation, *Stef Graillat, Philippe Langlois and Nicolas Louvet*](https://projecteuclid.org/download/pdf_1/euclid.jjiam/1265033778) * * see also [[2] *Philippe Langlois, Nicolas Louvet.* Faithful Polynomial Evaluation with Compensated Horner Algorithm. ARITH18: 18th IEEE International Symposium on Computer Arithmetic, Jun 2007, Montpellier, France. pp.141–149. ffhal-00107222f](https://hal.archives-ouvertes.fr/hal-00107222/document) * * see also [[3] Horner's Method](https://en.wikipedia.org/wiki/Horner%27s_method) * * @internal */ function HornerAbsSum( p1: number[], p2: number[], x: number): number { //-------------------------------------------------------------------------- // This is used in algorithms in [2] above //-------------------------------------------------------------------------- let q = 0; for (let i=0; i