numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersRaisesReturns
trimcoef(c, tol=0)

"Small" means "small in absolute value" and is controlled by the parameter :None:None:`tol`; "trailing" means highest order coefficient(s), e.g., in [0, 1, 1, 0, 0] (which represents 0 + x + x**2 + 0*x**3 + 0*x**4 ) both the 3-rd and 4-th order coefficients would be "trimmed."

Parameters

c : array_like

1-d array of coefficients, ordered from lowest order to highest.

tol : number, optional

Trailing (i.e., highest order) elements with absolute value less than or equal to :None:None:`tol` (default value is zero) are removed.

Raises

ValueError

If :None:None:`tol` < 0

Returns

trimmed : ndarray

1-d array with trailing zeros removed. If the resulting series would be empty, a series containing a single zero is returned.

Remove "small" "trailing" coefficients from a polynomial.

See Also

trimseq

Examples

>>> from numpy.polynomial import polyutils as pu
... pu.trimcoef((0,0,3,0,5,0,0)) array([0., 0., 3., 0., 5.])
>>> pu.trimcoef((0,0,1e-3,0,1e-5,0,0),1e-3) # item == tol is trimmed
array([0.])
>>> i = complex(0,1) # works for complex
... pu.trimcoef((3e-4,1e-3*(1-i),5e-4,2e-5*(1+i)), 1e-3) array([0.0003+0.j , 0.001 -0.001j])
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/polynomial/polyutils.py#156
type: <class 'function'>
Commit: