<s>[INST] Diophantine equation in a polynomial ring 
I have to calculate the inverse of the polynomial $(2x^2+x+1)$ in the quotient ring $\frac{Z_3[x]}{<x^3+2x+2>}$. 

My idea was that I could solve the following equation, but I have no idea where to begin:$$(x^3+2x+2)u+(2x^2+x+1)v = 1.$$
 [/INST] Hint:
The general method, for any base field, is to use the Extended Euclidean algorithm to obtain a Bézout's relation:
$$u(x)(2x^2+x+1)+v(x)(x^3+2x+2)=1.$$
The the inverse of $2x^2+x+1$ modulo $x^3+2x+2$ is simply $v(x)$.
Here is a layout. Note that $2x^2+x+1=-x^2+x+1$, so, to simplify the computations we'll apply the algorithm to $x^3+2x+2=x^3-x-1$ and $x^2-x-1$:
$$\begin{array}{rccl}
r(x)&u(x)&v(x)&q(x)\\
\hline
x^3-x-1&0&1\\
x^2-x-1&1&0& x+1\\
\hline
x&-x-1&1&x-1\\
-1&x^2&-x+1\\
\hline
\end{array}$$
Thus we have $\;-1=x^2(x^2-x-1)+(-x+1)(x^3-x-1)$, or
$$1=x^2(2x^2+x+1)-+(x-1)(x^3+2x+2),$$
and the inverse of $2x^2+x+1$ is $x^2 $.
</s>