07-18-2020, 09:30 AM
NumPy polymulx()
The function multiplies the polynomial with a value which is the independent variable.
Arguments |
Type |
Description
c |
array_like or poly1d object |
The input polynomials to be multiplied
The following table shows the return value of the function:
|
Type |
Description
[b]Return Value[/b] |
ndarray or poly1d object |
The polynomial resulting from the multiplication of the inputs. If either inputs is a poly1d object, then the output is also a poly1d object. Otherwise, it is a 1D array of polynomial coefficients from highest to lowest degree.
Let’s dive into some examples to show how the function is used in practice:
Examples
This function is inspired from thisGithub repository.
Any master coder has a “hands-on” mentality with a bias towards action. Try it yourself—play with the function in the following interactive code shell:
https://repl.it/@finxter/polyx?lite=true
Exercise: Change the parameters of your polynomials and print them without the comparisons. Do you understand where they come from?
Master NumPy—and become a data science pro:
![[Image: Cover_Coffee_Break_NumPy_v2-1-683x1024.png]](https://blog.finxter.com/wp-content/uploads/2019/04/Cover_Coffee_Break_NumPy_v2-1-683x1024.png)
Related Video
Code:
numpy.polynomial.polynomial.polymulx(c)The
Code:
numpy.polymulxCode:
cCode:
xArguments |
Type |
Description
c |
array_like or poly1d object |
The input polynomials to be multiplied
The following table shows the return value of the function:
|
Type |
Description
[b]Return Value[/b] |
ndarray or poly1d object |
The polynomial resulting from the multiplication of the inputs. If either inputs is a poly1d object, then the output is also a poly1d object. Otherwise, it is a 1D array of polynomial coefficients from highest to lowest degree.
Let’s dive into some examples to show how the function is used in practice:
Examples
Code:
import numpy as np
import numpy.polynomial.polynomial as poly print(poly.polymulx([0]) == [0])
print(poly.polymulx([1]) == [0, 1])
for i in range(1, 5): ser = [0]*i + [1] tgt = [0]*(i + 1) + [1] print(poly.polymulx(ser) == tgt) '''
[ True]
[ True True]
[ True True True]
[ True True True True]
[ True True True True True]
[ True True True True True True] '''This function is inspired from thisGithub repository.
Any master coder has a “hands-on” mentality with a bias towards action. Try it yourself—play with the function in the following interactive code shell:
https://repl.it/@finxter/polyx?lite=true
Exercise: Change the parameters of your polynomials and print them without the comparisons. Do you understand where they come from?
Master NumPy—and become a data science pro:
![[Image: Cover_Coffee_Break_NumPy_v2-1-683x1024.png]](https://blog.finxter.com/wp-content/uploads/2019/04/Cover_Coffee_Break_NumPy_v2-1-683x1024.png)
Related Video

