Question: C++ A single variable polynomial is represented as an arithmetic expression show below: A 0 + A 1 * x + A 2 * x
C++
A single variable polynomial is represented as an arithmetic expression show below:
A0 + A1 * x + A2* x2 + + Ak* xk
The highest exponent, k, is called the degree of the polynomial, and the constants A0, A1, , Ak are the coefficients. For example, here are two polynomials with degree 3:
2.1 + 4.8x + 0.1x2 + (-7.1)x3
2.9 + 0.8x + + 1.7x3
Specify, design, and implement a class for polynomials. The class may contain a static member constant, MAXDEGREE, which indicates the maximum degree of any polynomial (this allows you to store the coefficients in an array with a fixed size). The default constructor will be one which will initialize the polynomial with all coefficients set to zero. In addition, you must have another constructor that takes has two parameters: degree, and coefficient_array which are used to initialize the polynomial appropriately. In addition you should have a member function that gets and sets the value of an appropriate coefficient. For example, polynomial::get(k) returns the coefficient of xk, and polynomial::set(k, 24.5) sets the coeeficient of xk to 24.5.
You should provide a member function for adding two polynomials, subtracting one polynomial from other, and evaluating a polynomial value for specific value of x, say x = 5.7.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
