Make a new directory named esc101-lab09 and put all your
programs in that directory.
In this lab we will extend the Polynomial class (discussed in lectures) in
several ways.
1. There is a bug in the addition method of AlgebraicTerm class. It currently
allows adding, for example, xy and xy^2. As such this is not allowed. Also, you
should print out an appropriate message when such an attempt is made.
Incorporate these fixes.
2. Include methods to subtract and multiply algebraic terms. Note that I can
multiply any two algebraic terms.
3. Include a method to return the exponent of a particular variable in an
algebraic term.
4. Make a constructor in the Polynomial class for building univariate
polynomials. This constructor should make use of the univariate algebraic term
constructor.
5. Include a method in the Polynomial class to compact a polynomial. For
example, a polynomial object may have the following terms: 3xy, -4x, 7y, -xy.
After compaction, it should have three algebraic terms: 2xy, -4x, 7y.
6. There is a bug in the addition method of the Polynomial class. Currently, it
assumes ordered terms. Eliminate all assumptions.
7. Add methods to do subtraction and multiplication of polynomials.
8. Include a method to determine the degree of a polynomial. Define the degree
of a multivariate polynomial to be the sum of the exponents of all the variables
in a term such that this sum is maximized.
9. Include a method to find out if a polynomial is univariate or multivariate.
10. Include a method to find a root of a polynomial if it is univariate. Use the
bisection method.
Following two problems are extra, meant for practice:
11. Include a method to partially differentiate a polynomial with respect to a
variable. Partial differentiation with respect to a variable is carried out by
treating all other variables as constants.
12. Using the differentiation method and the bisection method find an extremum
of a polynomial if it is univariate. Also, find a way to notify the caller about
the nature of the extremum i.e. minimum or maximum.