# Alias for root of a polynomial

I need to work with a variable $$u$$ such that $$u^2 + u + 1 = 0$$. I don't want to find a root of the polynomial $$u^2 + u + 1$$. Rather, I have to work with $$u$$ symbolically so that a (polynomial) expression in $$u$$ gets simplified using the equation $$u^2 + u + 1 =0$$.

For example, let

y = Series[u + 1 + u*x + x^2, {x, 0, 4}]
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}]


Then, I'd expect

SeriesCoefficient[y+z, 0] = 0
SeriesCoefficient[y+z, 1] = -1


Thank you.

• I'm a Python/R user, this is unintelligible to me, can you explain without Mathematica jargon please? – smci May 14 at 5:51

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 *)

• With y = Series[u + 1 + x^2, {x, 0, 4}] your method produces u^2 for Assuming[assume, SeriesCoefficient[y + z, 1] // Simplify]. I think the expected result is -1-u. – Carl Woll May 13 at 20:26
• @CarlWoll - I do not know what is "expected", but LeafCount /@ {u^2, -1 - u} indicates that u^2 is simpler in the usual sense. – Bob Hanlon May 13 at 20:30

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)$$

• Carl, what does the Block[{u}, ...] do here? I think I'm still confused about the usage of Block. – Roman May 13 at 15:46
• @Roman The Block is needed so that recursion is avoided (preventing evaluation of u^n on the right hand side) – Carl Woll May 13 at 16:00
• I get Iteration limit exceeded with $1/u$. – Myath May 13 at 17:40

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$$.