Python Program to Remove Small Trailing Coefficients from Chebyshev Polynomial
Input: [-1, 0, 2, 0]
Output: [-1. 0. 2.]
Explanation: One dimensional array in which trailing zeroes are removed.
Python provides a method called NumPy.polynomial.Chebyshev removes the trailing zeroes in a polynomial. This method accepts a one-dimensional (1D) array that consists of coefficients of a polynomial starting from lower order to higher order and returns a one-dimensional (1D) array in which trailing zeroes are removed. Let’s consider a polynomial 0x3+2x2+0x-1 and for the given polynomial, the coefficient array is [-1, 0, 2, 0] starting from lower-order constant to higher-order x3. The chebtrim method will remove the trailing zeroes and return the resultant coefficient array.
- arr: 1-d array of coefficients.
Returns: trimmed ndarray.
Python program to remove the small trailing coefficients for the polynomial 0x3+2x2+0x-1.
The x3 coefficient is removed because there is no significance for the higher-order term as its coefficient is zero.
[-1. 0. 2.]
Python program to remove the small trailing coefficients for the polynomial 0x5+0x4+x3-x2+10x+0.
The coefficients of x4 and x5 are removed by the chebtrim method from the input array of coefficients.
[ 0. 10. -1. 1.]
Python program to remove the small trailing coefficients for the polynomial 4x4+3x3-2x2-1x+0.
Here no coefficients are removed by the chebtrim method as there are no trailing zeroes.
[ 0. -1. -2. 3. 4.]