flopscope.

flopscope.numpy.polysub

Difference (subtraction) of two polynomials.

Adapted from NumPy docs np.polysub

Areacore
Typecustom
NumPy Refnp.polysub
Cost
max(n1,n2)\max(n_1, n_2)
Flopscope Context

Difference (subtraction) of two polynomials. Cost: max(n1, n2) FLOPs.

Note.

This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in flops.polynomial is preferred. A summary of the differences can be found in the transition guide.

Given two polynomials a1 and a2, returns a1 - a2. a1 and a2 can be either array_like sequences of the polynomials' coefficients (including coefficients equal to zero), or poly1d objects.

Parameters

a1, a2:array_like or poly1d

Minuend and subtrahend polynomials, respectively.

Returns

out:ndarray or poly1d

Array or poly1d object of the difference polynomial's coefficients.

See also

Examples

(2x2+10x2)(3x2+10x4)=(x2+2)(2 x^2 + 10 x - 2) - (3 x^2 + 10 x -4) = (-x^2 + 2)
>>> import flopscope.numpy as fnp
>>> flops.polysub([2, 10, -2], [3, 10, -4])
array([-1,  0,  2])