Example of factorization in a polynomial ring which is not an UFD I'm looking for a particular example of a polynomial ring $A[x]$, with $A$ integral domain, which is not an UFD. An easy example is $\mathbb{Z}[\sqrt{-5}][x]$, here $6 x^2 = (2x)(3x) = ((1+\sqrt{-5})x)((1-\sqrt{-5})x)$.
I would like to find a ring and a polynomial where the problem is not only in the coefficients. In other words a ring $A[x]$ where there exist a polynomial $f \in A[x]$ with two factorizations that are not of the form $f = (a_1g)(b_1h) = (a_2 g)(b_2h)$, with $g,h \in A[x]$, $a = a_1b_1 = a_2b_2 \in A$ (with $a_1b_1, a_2b_2$ two factorization of $a$). Or not of a similar form with more factors.
 A: Perhaps this is the sort of thing you are looking for: If $a,b,c,d\in A$ are irreducible non-associate elements such that $ab=cd$, then
$$
(ax+c)(dx-b) = adx^2 - bc = (ax-c)(dx+b).
$$
With $A = \mathbb{Z}[\sqrt{-5}]$, taking $(a,b,c,d) = (2,3,1+\sqrt{-5},1-\sqrt{-5})$, this
results in
$$
(2x+1+\sqrt{-5})((1-\sqrt{-5})x-3) = (2x-1-\sqrt{-5})((1-\sqrt{-5})x+3).
$$
However, you might still see this a kind of cheat, since $ax+c$ and $dx+b$ actually are scalar multiples; it's just that the scalar factor, $d/a = b/c$, isn't in $A$ but is instead in its field of fractions.  But this is unavoidable:  over the field of fractions, polynomials do have unique factorization; so seemingly distinct factorizations into linear factors over $A$ necessarily become identical aside from units over the field of fractions.
Another possibility is to use a higher-order polynomial that is irreducible over $A$, but not over the field of fractions.  For example, if $ab=cd$ then
$$
(ax+c)(ax+d) = a(ax^2 + (c+d)x + b).
$$
In $\mathbb{Z}[\sqrt{-5}]$, this might be realized as
$$
(2x + 1 + \sqrt{-5})(2x + 1 - \sqrt{-5}) = 2(2x^2 +2x + 3).
$$
This is, in essence, an example of the failure of Gauss's lemma for a non-UFD.  I found the idea for this example in David E Speyer's answer to a MathOverflow question; the other responses may also be of interest.
A: When $A$ is not a domain, decomposing a polynomial in $A[x]$ as $f=gh$ does not necessarily simplify it, that is, does not always reduce its degree.
For instance:
$$
5x+1=(2x+1)(3x+1) \bmod 6
$$
It is even possible to decompose a linear polynomial as a product of two quadratic polynomials:
$$
x+1=(2x^2+x+7)(4x^2+6x+7) \bmod 8
$$
