# Dividing in $\mathbb{Z}_m[x]/p(x)$

how can I divide for example $\frac{x^2+1}{2x+1}$ in $\frac{\mathbb{Z}_3[x]}{x^3+1}$? It's like normal polynomial dividing but here I got in first step $\frac{x}{2} (\frac{x^2}{2x}=\frac{x}{2}$).What is the modulo value of this statement? I need it for solve a linear equation solve, it's part of the Euclidan algorithm..but here I am stuck and I don't know what to do..Right answer is 2x+2 with remainder 2..But I don't know WHY:D

Please help..And please be patience for my poor English and absence of right formatting, today I've an exam so I am a bit hurry:D

-
As you're calculating modulo $3$, you have $2 = -1$. – j.p. Jan 3 '11 at 11:11
Oh!Excellent..So if I am dividing with larger factor(multiple of x), I flip it like this..and I got -x equals 2x..So thanks a lot!! – simekadam Jan 3 '11 at 11:20
Be a bit careful. In $Z_3, 2=\frac{1}{2}$, but in other fields it does not. In $Z_{13}$, for example, $7=\frac{1}{2}$, so you don't just "flip it". – Ross Millikan Jan 3 '11 at 11:22
I don't mean to flip the fraction ($\frac{1}{2}$ to $\frac{2}{1}$), but to flip or revert the modulo value to a better one usable for dividing..So in your example it will be like $7=-6 Z_{13}$..Another way.I am not sure if I can divide two "undivisible" numbers…Wait, maybe I am dummy..I need an inverse for every divide:DSorry Sorry..It's to confusing for me these congruence modulo things.. – simekadam Jan 3 '11 at 11:32
$Z_p$ is a field for prime $p$, so every non-zero element will have an inverse. If $p$ is not a prime, you need the element to be coprime to $p$ – Ross Millikan Jan 3 '11 at 13:16

HINT $\rm\ \ 3 \equiv 0\ \Rightarrow\ 1 + 2\ x \:\equiv\: 1-x\:.\$ Now $\rm\ x^3\:\equiv\:-1\ \Rightarrow\ x^2+1\ \equiv\ x^2 -x^3\ \equiv\ x^2\ (1-x)\$
Therefore $\rm\ (x^2+1)/(1-x)\ \equiv\ \ldots$