<s>[INST] Factoring $x^4 + 12x^3 + 46x^2 + 59x + 18$ 
How do I factorize the following?
$$x^4 + 12x^3 + 46x^2 + 59x + 18$$

I've tried looking for a root by trial and error to no avail.
The answer is
$$(x^2 + 5x + 2)(x^2 + 7x + 9)$$
 [/INST] The first step is check for linear factors.  By the rational roots theorem, the only possible rational roots are $\pm 1, \pm 3, \pm 9, \pm 2, \pm 6, \pm 18$.  Once you have eliminated linear factors, the only possible factorization is as two quadratics.
With that out of the way, a good general technique to look for factorizations is to reduce mod n for various n.  If $f(x)=p(x)q(x)$, then reducing mod n yields a factorization for $f(x) \pmod n$.  If $n$ is bigger than any of the coefficients of $p, q,$ or $f$, then we can read off the actual factorization from the modular factorization.
To figure out what primes we might attempt to reduce modulo, let us compute $f(k)$ for small values of $k$, as a factor here will yield that $k$ is a root mod that factor.
Working mod 2, we have $f(x)=x^4+x=x(x+1)(x^2+x+1)$, the last factor being irreducible mod 2.  Working mod 3, $f(x)=x^4+x^2-x=x(x+1)(x^2-x-1)$, the last term also being irreducible mod 3. Computing $f(k)$ for small values of $k$ and factoring to find primes such that $f(k)$ will have at least one linear factor, we see that $(x+8)$ will be a factor mod 13 and 17, and $(x-3)$ will b a factor mod 13.  We get $f(x)\equiv (x-3)^3(x+8) \pmod{13}$ and $f(x)\equiv (x+3)(x-1)(x-6)^2 \pmod{17}$.
Thus, either $p(x)\equiv (x-3)^2 \pmod{13}$ and $q(x)\equiv (x-3)(x+8) \pmod{13}$ or vice versa.  Similarly, $p(x)\equiv (x-6)^2,(x-6)(x-1),(x-6)(x+3)$, or $(x-1)(x+3)\pmod{17}.$
Just using the mod 13 and 17 information is enough to find the factors mod 221, which is enough to specify the factors entirely.  The mod 2 and 3 information serves as a good double-check.  There are still a few combinations to check, but it makes the problem tractable.
The advantage of this method is that when a factorization does NOT exist, this can potentially show that too, by narrowing down what the shape of the factorization would have to be, and getting contradictory information.  For example, if you had $f(x)=x^5+15x^2+3$, then mod 3, this would either factor as $x(x^4)$ or $x^2(x^3)$, and since the constant term is not divisible by $9$, neither of these can happen.  This particular case can be extended to Eisenstein's criterion, but the general idea is useful more broadly.
</s>