import { γγ } from '../../error-analysis/gamma.js'; import { ddMultDouble2 } from "double-double"; import { eEstimate } from "big-float-ts"; const γγ3 = γγ(3); /** * Returns the result (and resulting coefficient-wise error bound) of * differentiating the given polynomial (with coefficients given in * double-double precision) in double-double precision. * * @param pWithErr an object with 2 properties: `p`: a polynomial with * coefficients given densely as an array of double-double precision floating * point numbers from highest to lowest power, e.g. `[[5],[-3],[0]]` represents * the polynomial `5x^2 - 3x` **and** `pE`: the coefficient-wise error bound of * the input polynomial * * @doc */ function ddDifferentiateWithError( pWithErr: { p: number[][], pE: number[] }): { p: number[][], pE: number[] } { const { p, pE } = pWithErr; const d = p.length - 1; if (d <= 0) { return { p: [], pE: [] }; } const dp = new Array(d); const dpE = new Array(d); for (let i=0; i (deg & deg-1) === 0 const extraErr = (deg & deg-1) === 0 ? 0 : γγ3; const $c = eEstimate(c); dpE[i] = deg*pE[i] + Math.abs($c)*extraErr; } return { p: dp, pE: dpE }; } export { ddDifferentiateWithError }