What qualifies as a polynomial? I have a very simple question regarding the definition of polynomials (with real coefficients).
What I've seen so far in terms of defintions:

*

*A polynomial $p(x)$ is a function that can be written in the form $p(x)=\sum^n_{k=0} a_kx^k$ where $a_k$ are real numbers.


*A polynomial is an expression involving only addition, subtraction, multiplication and integer exponents.
Now $f(x) = (2x-1)(3x + 4)$ is a polynomial so the representation $\sum_{k=1}^n a_kx^k$ is not essential. Of course one can rewrite $f$ in the desired form.  If I have, say, the function
$$
p(x)=\frac{x^3-x^2+x-1}{x^2+1}
$$
then this is not a polynomial as it stands. However one can easily represent it as a polynomial by factoring out $x^2 + 1$. Another example that I wonder about is the function
$$
q(x)=\begin{cases} x^2+1 & \text{if } x>0 \\ x + 1 & \text{if } x \le 0\end{cases}
$$
The latter involves only the allowed operations, furthermore pointwise it is of the form $\sum_k^n a_kx^k$.
So my question is whether the examples $p$ and $q$ above are polynomials, and if not -- what is the precise definition of a polynomial ?
Thanks for your help!
 A: A polynomial is usually not considered as a function, which is a key distinction, though you can use a polynomial to define a function.  When we have a polynomial in a variable $x$, $x$ is frequently called an indeterminate.  This means that it is a symbol, not a number.  The way we get a function from a polynomial is called evaluation; it is the act of putting in specific real numbers in replacement of the indeterminate $x$.  But this is usually considered something we can do with a polynomial, and the polynomial itself is not thought of as a function.
We can multiply polynomials to get new polynomials (you just distribute through to get the $a_{i}$ needed to represent it in the form you give), but division by terms involving $x$ is not allowed.
For example, $(2x-1)(3x+4) = 6x^{2}+5x-4$ is a polynomial, but
$$\frac{x^{3}-x^{2}+x-1}{x^{2}+1}$$
is not a polynomial.  You are correct that we could do some cancellation to get a polynomial, the technical term here is that the function defined by this formula can be written as a polynomial function (or we would say that once we do some cancellation, we have a polynomial).
The piecewise function you gave is also not a polynomial; it involves one extra operation that is not allowed, which is essential the "conditional" part of the statement (that decides which formula to use).
A: Yes, it is enough to be expressible in the form $p(x)=\sum_{i=0}^ka_ix^i$ for some $k\geq0$ and $a_i\in\Bbb{R}$. This expression should hold for all $x\in\Bbb{R}$. So for example, your function
$$p(x)=\frac{x^3-x^2+x-1}{x^2+1},$$
is a real polynomial, because $p(x)=x-1$ holds for all $x\in\Bbb{R}$. But $p(x)$ isn't a complex polynomial because it isn't defined at $\pm i$.
