Write a function that multiplies two polynomials in HASKELL 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 x^2−1 to ?^3−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)

Question

Write a function that multiplies two polynomials in HASKELL

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 x^2−1 to ?^3−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)

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Object Oriented Programming

Programing Language

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Technician A says that the throttle position is an input to the PCM. Technician B says that the brak...

A: When brake pedal switch is pressed it sends an input to the PCM to maintain idle speed of a predefin...

Q: Consider a sample of carbon tetrafluoride that contains 1.09 × 10²⁴ atoms of fluorine. 1.) Using th...

A: In international system of unit, there are seven basic units. Out of those seven unit Mole is one of...

Q: Mustafa, Heloise, and Gia have written more than a combined total of 22 articles for the school news...

A: Given: Total articles 22.

Q: Use the reaction to complete. KOH+HBr-->KBr+H2O A student sets up a titration apparatus with 25 mL...

A: Given titration is acid base titration in which neutralization reaction takes place.

Q: 1.) In cell C19, insert a formula that will calculate the projected advertising spending after the f...

A: There are pair of fundamental approaches to execute computations in excel are Formulas and Functions...

Q: e. Write a formula to define the the length of the base of the window (in inches), b, in terms of th...

A: From part c we had: P=12πb+bWe now have to find a formula for b using this expressions. So we need t...

Q: Which has the larger radius, S or S2-? Explain.

A: Which has the larger radius, S or S2- has to be identified.

Q: There are three industrial firms in Happy Valley.The government wants to reduce pollution to 60 unit...

A: a) Firm B would like to purchase 20 permits from another firm as it has the biggest share of lowerin...

Q: Compound X has a molar mass of 134.12 g•mol -1 and the following composition: element mass % carbon ...

A: Element  Mass % Carbon 44.77 % Hydrogen 7.52 % Oxygen 47.72 %  

Q: accounts, adjusting entries, financial statements, and closing entries;optional end-of-period spread...

A: Given:

Q: A) In a polar covalent bond, the electrons in the bond will be closer to the more electronegative at...

A: In a polar covalent bond, the electrons in the bond will be closer to the more electronegative atom ...

Q: A chemist has a block of gold metal (density is 19.3 g/mL). They drop the metal into a graduated cyl...

A: Given data, Density = 19.3 g/mL Volume = 1.90 mL To calculate the mass in grams.

Q: In a test of the Law of Multiple proportions, two different compounds composed of elements A and B a...

A: For compound X B/A = 2.33/1.00 = 2.33   For compound Y B/A = 5.83/1.00 = 5.83   Divide these two num...

Q: You plan to pass alpha particles through a field that contains a consistent type of particle. Which ...

A: The higher the energy of the alpha particles, the faster is their velocities. Also, the larger the m...

Q: central idea of “Around the family drum” by Howard Rainer

A: The short story titled "Around the Family Drum" is written by Howard Rainer. The short story has bee...

Q: The normal recipe for preparing Kool-Aid® calls for adding the entire package and 1 cup of sugar to ...

A: To measure the volume percent of the solution, the units of the respective solute and solvents has t...

Q: Acrylonitrile and ethyl acetate have the same boiling point: 77.2ºC. How can I explain what outcome ...

A: Given: Acrylonitrile and ethyl acetate have the same boiling point : 77.2 ° C.  

Q: What will NEVER change? In a sequence of translations, reflections, and rotations, what will NEVER c...

A: Click to see the answer

Q: Aspirin (C9H8O4) is synthesized by reacting salicylic acid (C7H6O3) with acetic anhydride (C4H6O3). ...

A: Given: Mass of salicylic acid = 1.00 x 102g= 100g To find: The mass of acetic anhydride Maximum mass...

Q: Which of the following statements is (are) true? a. If the number of moles of a gas is doubled, the ...

A: Click to see the answer

Q: What is the ratio of the sun's gravitational force on you to the earth's gravitational force on you?

A: Given  A person is on earth surface .  Let gravitational force on person due to sun is  Fs .... Grav...

Q: Profit maximization and loss minimization BYOB is a monopolist in beer production and distribution i...

A: BYOB is a monopolist in beer production. Let BYOB cannot discriminate price and sell beer to all cus...

Q: If in some year gross investment was $240 billion and net investment was $130 billion, then in that ...

A: Given Information Gross Investment = $240 billionNet Investment = $130 billion  

Q: At the beginning of 2018, the Redd Company had the following balances in its accounts: Cash Inventor...

A: The question is based on the concept of Business Accounting.

Q: The cells shown in the image are from a rare species of plant and illustrate different stages of mit...

A: Cell division is an important process that helps to keep the cells growing in number. This enables a...

Q: Adjusting entry for customer refunds, allowances, and returnsStatz Company had sales of $1,800,000 a...

A: Merchandise business is that form of business in which goods are purchased and sold without performi...

Q: A soccer ball is kicked 8m north. Then a teammate kicks it 6m east into the goal. What is the soccer...

A: Click to see the answer

Q: Indicate whether the following experimental mistake will increase, decrease, or have no effect on th...

A:                 

Q: During 2021, José, a self-employed technology consultant, made gifts in the following amounts: To H...

A: Gifts made to customers are deductible up to $25 per each

Q: Retype the below code. Fix the indentation as necessary to make the program work. if 'New York' in ...

A: In Python, Indentation is used to highlight the blocks of code. Whitespace is used for indentation ...

Q: A cheetah spots a Thomson's gazelle, its preferred prey, and leaps into action, quickly accelerating...

A: Equation of motion: This is relate the displacement of an object with its velocity , time and accele...

Q: How much of each starting material would you use to prepare 2.00 L of each of the following solution...

A: The molarity of the substance can be calculated by dividing the moles of the substance by volume in ...

Q: Write a program using integers userNum and x as input, and output userNum divided by x four times. ...

A: Code: user_num = int(input())x = int(input()) for i in range(3):    user_num = user_num // x    pr...

Q: Determining Undefined Concepts Quick Check Which statements are true regarding undefinable terms in ...

A: Click to see the answer

Q: Provide an algorithm with the same time complexity as Bellman-Ford so that: it sets dist [w] to −∞fo...

A: Provide an algorithm with the same time complexity as Bellman-Ford so that: it sets dist [w] to −∞fo...

Q: a. If a constant c is added to each xi in a sample, yielding yi = xi + c, how do the sample mean and...

A: Mean: For a set of n observations, x1, x2, ... , xn mean is defined as, Median: For a frequency dis...

Q: Elijah and Anastasia are husband and wife who have five married children and nine minor grandchildre...

A: When a person transfer ownership of goods or property to another during his life at this time a tax ...

Q: Predict the approximate bond angles in the molecule. H2C=C=CH2 H−C−H angle: C=C=C angle:

A: The given molecule is an allene in which two double bonds are present in the same carbon atom. The g...

Q: A material will float on the surface of a liquid if the material has a density less than that of the...

A: Given: Density of water = 1.0 g/mL Volume = 1.2 × 104 in3 Mass = 3.5lb

Q: Myers-Briggs: Personality Types Isabel Briggs Myers was a pioneer in the study of personality types....

A: Probability is defined as the total number of favorable cases of an event divided by the total numbe...

Q: Use the following information for Taco Swell, Incorporated, (assume the tax rate is 21 percent): 202...

A: Income and balance sheet statements:

Q: Five groups of four vectors are shown below. All magnitudes of individual vectors are equal. Please ...

A: As seen from the figure, Q>P>R=S>T

Q: your sketch to find the absolute and local maximum and minimum values of f. (Enter your answers as a...

A: Click to see the answer

Q: E8-7 (Algo) Recording Depreciation and Repairs (Straight-Line Depreciation) LO8-2, 8-3 (The followin...

A: Journal entries to record the two expenditures during 2020: No. General Journal Debit Credit 1....

Q: President Barack Obama claimed that the United States should intervene in an attack on the Yezidi pe...

A: Genocide is the killing of large groups of people belonging to a certain ethnic group in order to de...

Q: Assume that in the short run a firm is producing 1,000 units of output, has average total costs of $...

A: Here, total output given is 1,000 units. Average total cost is $100. Average total cost is defined a...

Q: When is it competitively advantageous to be a first mover? Multiple Choice A) If the market respo...

A: Competitive Advantage can be described as any advantage that a particular company gets over its comp...

Q: A psychology class consists of 32 freshmen and 48 sophomores. If the professor selects names from th...

A: There are 32 freshmen and 48 sophomores. The total number of students is 32+48=80. 1. The probabilit...

Q: 5. A ball is shot from an air-cannon at an angle of 45° with the horizon. It travels along a path gi...

A: NOTE: Refresh your page if you can't see any equations. . to graph the function, we need a few poin...

Q: When analyzing a velocity vs. time graph to determine the constants in the kinematic equation v = Vo...

A: Given data: The kinetic equation V = Vo + at Linear equation y = mx + b