Question: In C++, Math with Polynomials -The first Picture is the question/program i need solving - Also requires you to add a test function as seen

In C++, Math with Polynomials

-The first Picture is the question/program i need solving

- Also requires you to add a test function as seen on the 2nd picture.

-I added a test output you can use as refrence at the end.

Thumbs Up if everything is included and runs correctly. Message if you need any other info. Comment best you can

In C++, Math with Polynomials -The first Picture is the question/program i

need solving - Also requires you to add a test function as

OUTPUT OF HOW IT SHOULD WORK

---------------------- P: [+3.0X^3 +2.0X^2 +X +5.0 ] Q: [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] ------- p + q ---------------------- [+3.0X^3 +2.0X^2 +X +5.0 ] + [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] = [+4.0X^4 +6.0X^3 +4.0X^2 +2.0X +10.0 ] VERIFIED ------- q + p ---------------------- [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] + [+3.0X^3 +2.0X^2 +X +5.0 ] = [+4.0X^4 +6.0X^3 +4.0X^2 +2.0X +10.0 ] VERIFIED ------- p - q ---------------------- [+3.0X^3 +2.0X^2 +X +5.0 ] - [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] = [-4.0X^4 ] VERIFIED ------- q - p ---------------------- [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] - [+3.0X^3 +2.0X^2 +X +5.0 ] = [+4.0X^4 ] VERIFIED ------- p * q ---------------------- [+3.0X^3 +2.0X^2 +X +5.0 ] * [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] = [+12.0X^7 +17.0X^6 +16.0X^5 +30.0X^4 +34.0X^3 +21.0X^2 +10.0X +25.0 ] VERIFIED ------- q * p ---------------------- [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] * [+3.0X^3 +2.0X^2 +X +5.0 ] = [+12.0X^7 +17.0X^6 +16.0X^5 +30.0X^4 +34.0X^3 +21.0X^2 +10.0X +25.0 ] VERIFIED ------- q / p ---------------------- [+3.0X^3 +2.0X^2 +X +5.0 ] / [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] = [] rem = [+3.0X^3 +2.0X^2 +X +5.0 ] VERIFIED ------- q / p ---------------------- [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] / [+3.0X^3 +2.0X^2 +X +5.0 ] = [+1.3X +0.1 ] rem = [+0.4X^2 -5.8X +4.4 ] VERIFIED [P] [Q] e[X]it p [P]: 6 x5 +4 x3 -2 x1 +3 x0 P: [+6.0X^5 +4.0X^3 -2.0X +3.0 ] Q: [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] ------- p + q ---------------------- [+6.0X^5 +4.0X^3 -2.0X +3.0 ] + [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] = [+6.0X^5 +4.0X^4 +7.0X^3 +2.0X^2 -X +8.0 ] VERIFIED ------- q + p ---------------------- [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] + [+6.0X^5 +4.0X^3 -2.0X +3.0 ] = [+6.0X^5 +4.0X^4 +7.0X^3 +2.0X^2 -X +8.0 ] VERIFIED ------- p - q ---------------------- [+6.0X^5 +4.0X^3 -2.0X +3.0 ] - [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] = [+6.0X^5 -4.0X^4 +X^3 -2.0X^2 -3.0X -2.0 ] VERIFIED ------- q - p ---------------------- [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] - [+6.0X^5 +4.0X^3 -2.0X +3.0 ] = [-6.0X^5 +4.0X^4 -X^3 +2.0X^2 +3.0X +2.0 ] VERIFIED ------- p * q ---------------------- [+6.0X^5 +4.0X^3 -2.0X +3.0 ] * [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] = [+24.0X^9 +18.0X^8 +28.0X^7 +18.0X^6 +30.0X^5 +10.0X^4 +25.0X^3 +4.0X^2 -7.0X +15.0 ] VERIFIED ------- q * p ---------------------- [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] * [+6.0X^5 +4.0X^3 -2.0X +3.0 ] = [+24.0X^9 +18.0X^8 +28.0X^7 +18.0X^6 +30.0X^5 +10.0X^4 +25.0X^3 +4.0X^2 -7.0X +15.0 ] VERIFIED ------- q / p ---------------------- [+6.0X^5 +4.0X^3 -2.0X +3.0 ] / [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] = [+1.5X -1.1 ] rem = [+4.4X^3 +0.8X^2 -8.4X +8.6 ] VERIFIED ------- q / p ---------------------- [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] / [+6.0X^5 +4.0X^3 -2.0X +3.0 ] = [] rem = [+4.0X^4 +3.0X^3 +2.0X^2 +X +5.0 ] VERIFIED [P] [Q] e[X]it q [Q]: 3 x8 P: [+6.0X^5 +4.0X^3 -2.0X +3.0 ] Q: [+3.0X^8 ] ------- p + q ---------------------- [+6.0X^5 +4.0X^3 -2.0X +3.0 ] + [+3.0X^8 ] = [+3.0X^8 +6.0X^5 +4.0X^3 -2.0X +3.0 ] VERIFIED ------- q + p ---------------------- [+3.0X^8 ] + [+6.0X^5 +4.0X^3 -2.0X +3.0 ] = [+3.0X^8 +6.0X^5 +4.0X^3 -2.0X +3.0 ] VERIFIED ------- p - q ---------------------- [+6.0X^5 +4.0X^3 -2.0X +3.0 ] - [+3.0X^8 ] = [-3.0X^8 +6.0X^5 +4.0X^3 -2.0X +3.0 ] VERIFIED ------- q - p ---------------------- [+3.0X^8 ] - [+6.0X^5 +4.0X^3 -2.0X +3.0 ] = [+3.0X^8 -6.0X^5 -4.0X^3 +2.0X -3.0 ] VERIFIED ------- p * q ---------------------- [+6.0X^5 +4.0X^3 -2.0X +3.0 ] * [+3.0X^8 ] = [+18.0X^13 +12.0X^11 -6.0X^9 +9.0X^8 ] VERIFIED ------- q * p ---------------------- [+3.0X^8 ] * [+6.0X^5 +4.0X^3 -2.0X +3.0 ] = [+18.0X^13 +12.0X^11 -6.0X^9 +9.0X^8 ] VERIFIED ------- q / p ---------------------- [+6.0X^5 +4.0X^3 -2.0X +3.0 ] / [+3.0X^8 ] = [] rem = [+6.0X^5 +4.0X^3 -2.0X +3.0 ] VERIFIED ------- q / p ---------------------- [+3.0X^8 ] / [+6.0X^5 +4.0X^3 -2.0X +3.0 ] = [+0.5X^3 -0.3X ] rem = [+2.3X^4 -1.5X^3 -0.7X^2 +X ] VERIFIED [P] [Q] e[X]it p [P]: 2 x12 P: [+2.0X^12 ] Q: [+3.0X^8 ] ------- p + q ---------------------- [+2.0X^12 ] + [+3.0X^8 ] = [+2.0X^12 +3.0X^8 ] VERIFIED ------- q + p ---------------------- [+3.0X^8 ] + [+2.0X^12 ] = [+2.0X^12 +3.0X^8 ] VERIFIED ------- p - q ---------------------- [+2.0X^12 ] - [+3.0X^8 ] = [+2.0X^12 -3.0X^8 ] VERIFIED ------- q - p ---------------------- [+3.0X^8 ] - [+2.0X^12 ] = [-2.0X^12 +3.0X^8 ] VERIFIED ------- p * q ---------------------- [+2.0X^12 ] * [+3.0X^8 ] = [+6.0X^20 ] VERIFIED ------- q * p ---------------------- [+3.0X^8 ] * [+2.0X^12 ] = [+6.0X^20 ] VERIFIED ------- q / p ---------------------- [+2.0X^12 ] / [+3.0X^8 ] = [+0.7X^4 ] rem = [] VERIFIED ------- q / p ---------------------- [+3.0X^8 ] / [+2.0X^12 ] = [] rem = [+3.0X^8 ] VERIFIED [P] [Q] e[X]it x 

Using dynamic arrays, implement a polynomial class with polynomial addition, subtraction, and multiplication Discussion: A variable in a polynomial does veiy little other than act as a placeholder for the coefficients. Hence, the only interesting thing about polynomials is the array of coefficients and the corresponding exponent. Think about the polynomial One simple way to implement the polynomial class is to use an array of doubles to store the coefficients. The index of the array is the exponent of the corresponding term. Where is the term in x*x in the previous example? If a term is missing, then it simply has a zero coefficient There are techniques for representing polynomials of high degree with many missing terms These use so-called sparse polynomial techniques. Unless you already know these techniques' or learn very quickly, don't use them Provide a default constructor, a copy constructor, and a parameterized constructor that enable an arbitrary polynomial to be constructed. Also supply an overloaded operator = and a destructor Provide these operations polynomial + polynomial constant +polynomial polynomial constant polynomial polynomial constant-polynomial polynomial constant polynomial * polynomial Const polynomial *constant Supply unctions to assign and extract coefficients, indexed by exponent. Supply a function to evaluate the polynomial at a value of type double You should decide whether to implement these functions as members, friends, or stand-alone functions ant *polynomial Using dynamic arrays, implement a polynomial class with polynomial addition, subtraction, and multiplication Discussion: A variable in a polynomial does veiy little other than act as a placeholder for the coefficients. Hence, the only interesting thing about polynomials is the array of coefficients and the corresponding exponent. Think about the polynomial One simple way to implement the polynomial class is to use an array of doubles to store the coefficients. The index of the array is the exponent of the corresponding term. Where is the term in x*x in the previous example? If a term is missing, then it simply has a zero coefficient There are techniques for representing polynomials of high degree with many missing terms These use so-called sparse polynomial techniques. Unless you already know these techniques' or learn very quickly, don't use them Provide a default constructor, a copy constructor, and a parameterized constructor that enable an arbitrary polynomial to be constructed. Also supply an overloaded operator = and a destructor Provide these operations polynomial + polynomial constant +polynomial polynomial constant polynomial polynomial constant-polynomial polynomial constant polynomial * polynomial Const polynomial *constant Supply unctions to assign and extract coefficients, indexed by exponent. Supply a function to evaluate the polynomial at a value of type double You should decide whether to implement these functions as members, friends, or stand-alone functions ant *polynomial

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!