The best way to understand a mathematical object is to play around
with it. You should experiment with its definition, push
its boundaries, and observe what happens. [1]

The first complex piece of math most people learn about is the
polynomial, and it's no exception to this rule. Let's see what we can
figure out about it.

### The Spreadsheet

Here's a spreadsheet for experimenting with polynomials.

(You'll need DataNitro, numpy and matplotlib for it
to work; please import the scripts "get_roots.py" and "functions.py"
before pressing the "get roots" button.)

The sheet lets you set the *degree*, or highest power of x, in
the polynomial, as well as the coefficients of the different powers of
x. It'll graph the polynomial, and find its *roots* for
you.

Let's look at the graphs first.

### Quadratic Equations

The simplest interesting polynomial has degree two: a quadratic
polynomial (like f(x) = x^{2} - 5x + 6). If we set a quadratic polynomial equal to zero, we get
a quadratic equation. [2]

Quadratic functions are counterintuitive, at least if you're used to
linear functions (like f(x) = 3x). Even the simplest
one, f(x) = x^{2}, is strange.

A linear function increases at a steady rate: whether you go from x =
1 to x = 2 or x = 101 to x = 102, f(x) = 3x will increase by 3. But
x^{2} increases by 3 as x goes from 1 to 2, by 23 as you from
11 to 12, and by 203 as you go from 101 to 102. [3]

For another thing, x^{2} is always positive - something that's
definitely not true for linear functions.

If you start solving quadratic equations, you'll notice something else that's
peculiar - sometimes, like with x^{2} = 0, they have one solution, just like a linear
equation.

But sometimes, they have two:

and sometimes they have none:

What's going on? Let's look at polynomials in general, and see if
we can figure it out. [4]

### Higher Degree Polynomials

A general polynomial is a sum of powers of x (f(x) = x^{3} +
5x^{2} + 6x + 1).

**Roots**: The roots of a polynomial f(x) are the values of x where f is
equal to zero. Why do we care about zero in particular? Well, we don't, but we do
care about equality: it seems worthwhile to be able to figure out when f(x) =
g(x). One of the nice things about polynomials is that you can add or
subtract two polynomials to get a third one. We'll know
when f is equal to g if we figure out when f(x) - g(x) is equal to
0.[5]

Here are a few things you might notice as you play with the model:

**1:** An n^{th} degree polynomial has
exactly n roots. [6] This doesn't agree with what we saw above, with
x^{2} = 0 and with x^{2} + 4 = 0. What's going on?

**2:** As we saw, some
quadratic equations have no roots on the graph. When we run
x^{2} + 4 through the spreadsheet, we its roots are 2i and
-2i. What does that mean?

i is called an imaginary number, and it's defined as the
square root of negative one. That is, i^{2} =
-1. [7]
Our spreadsheet can't graph it because it doesn't fit on a regular
number line, but if we accept it as a concept, we can see that it does
solve our equation:

^{2}+ 4 = 4(i)

^{2}+ 4 = -4 + 4 = 0.

**3:** In addition to imaginary roots,
some polynomials, like x^{2} - 4x + 4, have a single root listed
more than once. This is called the *multiplicitly* of the root,
and it's not obvious what it means. If 2 is a root of the
polynomial f, how do we know whether it's a root one time or twenty
times?

Roots are closely related to factoring a polynomial
- for example, the roots of x^{2} - 4x + 4 are 2 and 2, and you can
write x^{2} - 4x + 4 as (x-2)(x-2). We say that a root r has a
multiplicity greater than one if

(x-r) is a factor of the polynomial
more than once.

**4:** If you change a polynomial's coefficients
slightly, its roots will only change slight as well. For example,
x^{3} - 5x^{2} + 6x has roots 0, 2, and 3, and
x^{3} - 5x^{2} + 6x + 0.01 has roots -0.002, 2.005,
and 2.997.

This is a result of *continuity*, a property of functions. The
original idea behind continuity is that you can draw some functions
without lifting your pen from the paper - polynomials, for example -
while other functions have gaps. [8]
Continuous functions are "well-behaved" in all sorts of ways, and this
is one of them: if you give a continuous function a small
perturbation, its roots won't change dramatically.

**5:** You might also notice that the roots calculated by the spreadsheet aren't exact: they're
rounded to 3 decimal points. This is usually good enough - and we can get
much more accurate numbers if we need to - but it'd be best to have an exact answer.
We can use the quadratic formula for second degree equations to tell us that
of x^{2} - x - 1 are exactly (1 +
√5 )/2 and (1 -
√5 )/2, not
1.618 and -0.618.

This leads to a natural question: can we find the exact values of the roots of any polynomial? If we have a quadratic formula, is there a cubic formula? A quartic (4th degree) formula? A quintic (5th degree) one? [9] [10]

Footnotes:

[1] This is how real math is done:
people find new theorems and decide on new definitions by playing around.
Unfortunately, math isn't taught this way; I distinctly
remember memorizing the quadratic formula without understanding
how it worked.

[2] Constants (like f(x) = 3) and linear
functions (like f(x) = 2x + 3) are polynomials too, but they're
boring. Linear equations are trivial, unless you start doing
interesting things like adding variables or restricting yourself to
solving them with integers.

[3] I use both f and f(x) to refer to
polynomials (or functions in general). f is
the function itself, while f(x) represents the value of the function at one
point - for example, f(2) is the value of f at 2. f(x) is one way of representing
the abstract function, by describing the value it takes for any
input.

You can describe functions in other ways, too; as the
sum of two other functions, for example.

[4] When you're working on a problem,
it can be helpful to look at a more general version. The general
version is usually - though not always - harder to solve, but it can
bring some patterns to light that the specific case obfuscates.

[5] This demonstrates two general
concepts in mathematics: *closure* and *reduction*. Closure
is a formal property of some mathematical objects under some operations: an object
is *closed* with respect to an operation if using that
operation on the object will give you another object of the same type.
For example, integers are closed under addition: if you add two
integers you get another integer (1 + 1 = 2). Integers are also closed
under subtraction and multiplication, but not under division (2/3
isn't an integer).

Polynomials are closed under addition and
subtraction, which is why when we set two polynomials equal to each
other [f(x) = g(x)], we can reduce that equation to setting another
polynomial equal to 0 [f(x) - g(x) = 0]. Like integers, polynomials
are also closed under multiplication, but not under division; it's a
good exercise to convince yourself of this. (Once you do, here's a
follow-up question: how do the roots of a product of polynomials
relate to the roots of its factors?)

Reduction, on the other hand, is a general
problem solving technique: reducing one set of problems (when are two
polynomials equal?) to a simpler set of problems (when is a polynomial
equal to 0?) is a way to get more mileage from our work.

[6]
This is an elegant result, known as the "Fundamental
Theorem of Algebra". There are lots of different ways to prove it - if
you'd like to try, I'd recommend starting with quadratic polynomials
and using induction to work your way up.

[7] "Imaginary" is a misnomer. Imaginary numbers are hard to picture, but
that's because we're not used to them. They're just as concrete as negative
numbers, which are also "imaginary" - that is, they don't
obviously correspond to things in the real world.

In fact, mathematicians debated for centuries
whether negative numbers really existed - after all, you can't have
a negative apple. As it turns out, though, a negative apple is a useful concept in
describing what happens when you go from 4 apples to 3 apples,
regardless of whether negative apples "really" exist. Imaginary numbers
have similarly concrete, if slightly more esoteric, uses.
Calculating properties of electrical circuits, for instance.

[8] The modern definition of continuity
is much more refined.

[9] This is a hard question.

[10] Thanks for reading to the end of the
post! If you have any questions, to email me: ben@datanitro.com.