Alias for root of a polynomial
You can give u
an UpValues
for Power
:
u /: u^n_Integer := Block[{u},
If[n<0,
PolynomialMod[(-u-1)^-n, 1+u+u^2],
PolynomialMod[u^n,1+u+u^2]
]
]
Then:
y = Series[u + 1 + u x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2 x + x^4,{x, 0, 4}];
and:
y + z //TeXForm
$-x+x^2+x^4+O\left(x^5\right)$
You can use Assumptions
assume = u^2 + u + 1 == 0;
y = Series[u + 1 + u*x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}];
Assuming[assume, SeriesCoefficient[y + z, 0] // Simplify]
(* 0 *)
Assuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
(* -1 *)
The simplest methods are usually the best. I suggest
rule = {u^n_ :> {1, u, -1 - u}[[Mod[n, 3] + 1]]};
y + z /. rule
which will do what you want. Also, the following code
Table[u^n, {n, 0, 6}] /. rule
demonstrates that $u^3 = 1$ and the powers of $u$ are periodic with period $3$.