Question: we are going to create an abstract data type for quadratic equations of the form ax 2 + bx + c . Here are the
we are going to create an abstract data type for quadratic equations of the form ax bx c
Here are the functions that operate on quadratics.
makequadratica b c This creates and returns a quadratic ax bx c
coefficientq i Return the ith coefficient of the quadratic q That is if q is ax bx c then
coefficientq is a
coefficientq is b
coefficientq is c
The two functions above are the only ones that need to know about how quadratics are represented internally. Everything else uses and builds on the two functions above.
These functions perform arithmetic with quadratics.
addquadraticq q Takes two quadratics and returns the result of adding them
multiplyn q Takes a number n and returns the result of multiplying the quadratic by it ie n x q n x ax bx c
hasrealrootsq Takes a quadratic q and return true if it has one or two real roots, or false otherwise. Recall from basic algebra that a quadratic has real roots only if the discriminant is zero or positive.
differentiatequadraticq Differentiate the quadratic q ie perform dqdx Recall from basic calculus that if q ax bx c then dqdx ax b
Your task is to write these functions. You can choose any internal representation you wish.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
