Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tut] NumPy polymulx()

#1
NumPy polymulx()

numpy.polynomial.polynomial.polymulx©

The numpy.polymulx function multiplies the polynomial c with a value x 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
Return Value 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


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 this Github 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:

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:

Coffee Break NumPy

Related Video






https://www.sickgaming.net/blog/2020/07/...-polymulx/
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tut] Python Library Hijacking – A Simple Demonstration on NumPy xSicKxBot 0 1,249 11-22-2022, 01:48 AM
Last Post: xSicKxBot
  [Tut] How to Convert Pandas DataFrame/Series to NumPy Array? xSicKxBot 0 1,213 10-24-2022, 02:13 PM
Last Post: xSicKxBot
  [Tut] How to Print a NumPy Array Without Scientific Notation in Python xSicKxBot 0 1,217 10-20-2022, 11:44 AM
Last Post: xSicKxBot
  [Tut] Python – Return NumPy Array From Function xSicKxBot 0 1,184 10-16-2022, 03:49 AM
Last Post: xSicKxBot
  [Tut] How to Find the Longest String in a NumPy Array? xSicKxBot 0 1,100 09-19-2022, 11:34 AM
Last Post: xSicKxBot
  [Tut] Combine Images Using Numpy xSicKxBot 0 1,217 09-18-2022, 10:23 AM
Last Post: xSicKxBot
  [Tut] How to Iterate over a NumPy Array xSicKxBot 0 1,158 08-19-2022, 06:55 PM
Last Post: xSicKxBot
  [Tut] How to Convert a CSV to NumPy Array in Python? xSicKxBot 0 1,173 07-11-2022, 03:42 AM
Last Post: xSicKxBot
  [Tut] How to Call an Element from a Numpy Array? xSicKxBot 0 1,155 06-21-2022, 04:08 AM
Last Post: xSicKxBot
  [Tut] How to Extend a NumPy Array in Python xSicKxBot 0 1,111 06-13-2022, 04:59 PM
Last Post: xSicKxBot

Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016