## Solutions of Univariate Polynomials

### Continuation

Next we examine a polynomial of degree 3:

poly: x^3 + x^2 - 8*x - 12;

The computation of the zeroes is straightforward:

sol: solve (poly=0, x);

[x = 3, x = - 2]

The answer is again written as a list of two equations. We
know that for an equation of third degree we can expect three
solutions, so we assume that one of the solutions is a double
zero. Which one?

To answer that question, we type in **multiplicities**
and obtain this list:

m: multiplicities;

[1, 2]

This means that the first equation in the solution list has
multiplicity one, while the second solution has multiplicity two.

To proceed, we rewrite the equations as terms:

terms: map( lambda( [eq], lhs(eq) - rhs(eq)), sol);

[x - 3, x + 2]

Now we have to use the multiplicities to form the correct factors:

map(lambda ( [term, exponent], term^exponent), terms, m);

2
[x - 3, (x + 2) ]

This time we used **map** with a symbolic function with two arguments.
For such a function, we have also to provide two lists of arguments.

No we can again apply multiplication:

apply("*", %);

2
(x - 3) (x + 2)

This is a polynomial in factored form. Expansion gives us the
initial polynomial:

expand(%);

3 2
x + x - 8 x - 12

It is of course possible to put all these computations into
one single expression:

expand(apply("*", map( lambda( [eq, exponent], (lhs(eq) - rhs(eq))^exponent),
sol,
multiplicities
) ) );

The innermost expression (here the **map**) is evaluated first. This is not a
surprise: The result of **map** is needed to perform the **apply** and
the result of **apply** is needed to perform the **expand**.

### What we have learned:

- After we have computed the zeroes of an univariate polynomial,
we find the multiplicities of the zeroes in the variable
**multiplicities**.
**map** can assemble several lists into one list. The number of lists that
is supplied to **map** has to agree with the number of formal arguments of
the function that processes the list elements.