My apologies if this has been asked before. Please also be gentle, as this is my first question here.
I am trying to define a commutative algebra by generators and relations in the following way. For a simple example, we can consider the Z[b] algebra generated by a, modulo a^2=b. I would like to introduce a rule (or a list of rules in more complicated examples):
In[1]: TheAlgebra = a*a -> b
It would be cool to evaluate products like this:
In[2]: a^3 //. TheAlgebra
However, this input simply returns the symbol a^3
. I would have expected the result a*b
. The following input works though:
In[2]': (a*a//.TheAlgebra)*a //. TheAlgebra
My question is this: how can I get Mathematica to simplify an expression such as a^kb^l in a smart way? There are similar questions on the site, but maybe the answer for this one is simpler, since I'm only interested in simplifying products of the various symbols together with some integers.
Maybe there is a way to force Mathematica to write a^3
in a full-form expression that I like, such as: Times[a,Times[a,a]]
?
a^3 //. {a^n_ /; n >= 2 :> a^(n - 2)\[CircleTimes]b}
do what you want? $\endgroup$GroebnerBasis
andPolynomialReduce
. They are made for exactly this type of computation. $\endgroup$