The purpose of this project is to test your ability to use dynamic memory (mixed with classes), operator overloading, and libraries effectively in program design.

Create a class for an algebraic formula in a single variable. As a reminder, such a formula has the form:

n n-1 2 1 0 a x + a x + ... a x + a x + a x n n-1 2 1 0

Or:

n ----- \ i > a x / i ----- i=0

(Same formula, different format...)

Construct the formula from the variable name (char or String?) and the number of terms. Overload subscript to allow your user to set/access the coefficients. (Coefficients should start as 0 by default.)

Overload output to print the formula as neatly as possible (you won't need the subscripts; you may use ^ instead of the superscripts). Ignore input for now...that can get pretty twisted.

Overload addition to add two such formulas (if you take the variable name
into account, adding two formulas in different variables should result in
an empty formula; that's a head-ache we don't need right now) —
element-wise add the coefficients (a_{0} of the first formula plus a_{0} of the
second formula). You should be able to add formulas with a different
number of coefficients.

Overload multiplication between a formula and a scalar (single real number value) so that the programmer can multiply either 'scalar * formula' or 'formula * scalar'. The result (either way) should be the scalar multiplied element-wise by all the coefficients.

Addition, subtraction, and division by a scalar should be done as well.
(You may find having an operator - in unary form handy for the subtraction
implementation...*wink,wink* *nudge,nudge* Say no more...) (Warning!
'formula / scalar' is
well defined, but 'scalar /
formula' is *way* beyond the scope of this programming
assignment!)

While overloading assignment, do +=, -=, *=, and /= similarly to above.

Include any other constructors, destructors, or methods that seem necessary/useful. (Maybe one for returning the order — highest power — of the formula would be nice. And for returning the variable name? *shrug*)

Write a driver to show off your formula class' abilities.

This assignment is (Level 6) before options.

Add (Level 2.5) to add a roots function which will return a container with all the

*rational*zeros of the formula. (Wasn't there a 'rational roots theorem' or something that might be useful here?) (There is also a boundedness theorem, but it is harder to find. Make sure you mention it in conjunction with synthetic division — more on that below.)(If you use an array, you may 'cheat' and have the first element hold the number of roots. So the array will be n+1 long if there are n roots.)

Tip: Synthetic division is excellent both here and for evaluating a polynomial at a particular value of the variable!

While we're on the subject, why not add (Level 1) to add an evaluate method to allow the programmer to evaluate the formula at a particular value of the variable. (Maybe you could use this to help implement the previous option..?)

If you wanted to extend that synthetic division and even enhance that a bit, you could implement full polynomial division — not just polynomial-by-scalar division. If you do, you can earn (Level 4) more.

To provide a sort of completeness quality and a helpful self-check ability, you could implement grid multiplication for your polynomials. (Don't read past the first part to the grid division algorithm, it is not as flexible as synthetic division and not as space efficient, either.) Doing so would be worth another (Level 1.5). (No — grid multiplication isn't space efficient, either. But it is easy to implement and doesn't have any immediate competition in that aspect!)

Add (Level 1) to print the formula on two lines (powers of the variable as superscripts) and make it line up nicely!