Write a function that multiplies two polynomials.
multPoly :: (Num a, Eq a) => Poly a -> Poly a -> Poly a
For example:
> multPoly (P [-1,0,1]) (P [0,1])
P [0,-1,0,1]
> multPoly (P [-1,0,1]) (P [2])
P [-2,0,2]
> multPoly (P [1,1]) (P [-1,1])
P [-1,0,1]
> multPoly (P [18,0,3]) (P [])
P []
Before writing multPoly, you may find it helpful to write a function that increases the degree of a polynomial by multiplying it by x. E.g., mapping x2−1x2−1 to x3−xx3−x. Seeing how this function, scale, and addPoly are written should give you a sense of how to construct multPoly. As with addPoly, multPoly is easier to write as a combination of simpler functions.
Your implementation of multPoly should have this property: multPoly p q $$ x == (p $$ x) * (q $$ x)
Extracted text: 5. Write a function that multiplies two polynomials. multPoly : (Num a, Eq a) => Poly a -> Poly a -> Poly a For example: > multPoly (P [-1,0,1]) (P [0,1]) P [0, -1,0,1] > multpoly (P [-1,e,1]) (P [2]) P [-2,8,2] > multpoly (P [1,1]) (P [-1,1]) P [-1,8,1] > multPoly (P [18,8,3]) (P []) P [] Before writing multPoly, you may find it helpful to write a function that increases the degree of a polynomial by multiplying it by x. E.g., mapping x? – 1 to x. x. Seeing how this function, scale, and addPoly are written should give you a sense of how to construct multPoly. As with addPoly, multPoly is easier to write as a combination of simpler functions. Your implementation of multPoly should have this property: multpoly p a $$ x == (p ss x) * (q ss x)