/** * Returns the result of differentiating the given polynomial in double * precision. * * @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` * * @example * ```typescript * differentiate([5, 4, 3, 2, 1]); //=> [20, 12, 6, 2] * ``` * * @doc */ function differentiate(p: number[]): number[] { const d = p.length - 1; if (d <= 0) { return []; } const result = new Array(d); for (let i=0; i