numpy.polymul () in Python

NumPy | Python Methods and Functions

The numpy.polymul (p1, p2) method computes the product of two polynomials and returns the polynomial obtained by multiplying the two input polynomials & # 39; p1 & # 39; and & # 39; p2 & # 39 ;.

Parameters:
p1: [array_like or poly1D] Input polynomial 1 .
p2: [array_like or poly1D] Input polynomial 2.

Return: Polynomial resulting from multiplication of the inputs.

If any of the input is a poly1D object, then otherwise the output is also a poly1D object, an array of 1D polynomial coefficients in decreasing order of degree.

Code: Python code explaining polymul ()

# Python code explaining
# numpy.polymul ()

 
# import libraries

import numpy as np

import pandas as pd

  
# Plotting a polynomial

p1 = np.poly1d ([ 1 , 2 ]) 

p2 = np.poly1d ([ 4 , 9 , 5 , 4 ]) 

 

print ( "P1:" , p1) 

print ( "p 2: " , p2) 

mul = np.polymul (p2, p1)

 

print ( "poly1D object:" )

print ( "Multiplication Result :" , mul)

# Definition of n darray

x = np.array ( [ 1 , 2 ])

y = np .array ([ 4 , 9 , 5 , 4 ])

mul = np.polymul (y, x)

 

print ( "1D array:" )

print ( "Multiplication Result :" , mul)





Get Solution for free from DataCamp guru