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...


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)


5. Write a function that multiplies two polynomials.<br>multPoly : (Num a, Eq a) => Poly a -> Poly a -> Poly a<br>For example:<br>> multPoly (P [-1,0,1]) (P [0,1])<br>P [0, -1,0,1]<br>> multpoly (P [-1,e,1]) (P [2])<br>P [-2,8,2]<br>> multpoly (P [1,1]) (P [-1,1])<br>P [-1,8,1]<br>> multPoly (P [18,8,3]) (P [])<br>P []<br>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.<br>x. Seeing how this function, scale, and addPoly are<br>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.<br>Your implementation of multPoly should have this property: multpoly p a $$ x == (p ss x) * (q ss x)<br>

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)
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here