The elimination in Lab's answer essentially employs the extended Euclidean algorithm to compute a Bezout identity. As usual, when we need only the result, such calculations can be simplified using modular arithmetic (so simple they can often be done mentally with practice). For example
$$\begin{eqnarray}
2n^2+1\ &\,\mid &\, n^3+9n-17\\[.2em]
\Rightarrow\ {\rm mod}\,\ \color{#0c0}{2n^2}\!+\color{#c00}1\!:\ \ 0 &\equiv&\, 2\,(n^3+\ 9n\,-\,17)\\[.2em]
&\equiv&\, \color{#0a0}{2n^2}n + 18n -34\\[.2em]
&\equiv&\, 17(n\!-\!2)\ \ \ {\rm by}\ \ \ \color{#0a0}{2n^2}\equiv -\color{#c00}1\\[.2em]
2(\color{#90f}{n\!+\!2})\times{\rm prior}\,\Rightarrow\ \ 0 &\equiv&\, 34(n\!-\!2)(\color{#90f}{n\!+\!2})\\[.1em]
&\equiv&\, 17\cdot\color{#0a0}{2n^2}-34\cdot 4\equiv -153
\end{eqnarray}\qquad\qquad$$
Remark $\ $ The multiplication by the factor $\,2(\color{#90f}{n\!+\!2})\,$ in the 2nd last step is not ad-hoc. Rather, it corresponds to taking the "norm" of a quadratic number, since here we have that $\, \color{#0a0}{n^2} \equiv -1/2\,$ so, ring-theoretically, $\,n\,$ behaves like $\,\sqrt{-1/2} = \sqrt{-2}/2,\,$ so we can do things like taking "norms" of expressions involving the "surd" $\,n,\,$ in order to get a simpler multiple, by mapping "irrational" obects into "rational" objects - as I did above, viz. $\,0\equiv \alpha\,\Rightarrow\, 0\equiv 2 N(\alpha) = 2\alpha\alpha'\equiv -153.$
We can also do the above computation using a slight generalization of the Euclidean algorithm that allows us to scale by integers coprime to the gcd.
The reason why this works will become clearer when one learns about various universal viewpoints of ring-theoretic objects. To me this is one of the most beautiful aspects of algebra - dramatically illustrating the success and power of the abstraction of algebraic structures such as rings.