wolfram mathematica - I want to define f^2 to be 1 but leave f undefined -


i want, example, mathematica generate 7 + 5f if write expression (2+f) (3+f). want f^2 computed 1 (or other value assign it) f special undefined symbol. if define f^2:=1 tag power protected error message.

i mathematica newbie, self taught, please try answer in elementary fashion possible.

for record, trying define clifford algebra operations in n-dimensional space-time , being able make assignment tremendously simplify task.

generalized symbols e1,e2,e3,...,en

x = (a + a1 e1 + a2 e2 + a3 e3 + a4 e1 e2 - a5 e1 e3 + a6 e2 e3 +  a7 e1 e2 e3); y = (b + b1 e1 + b2 e2 + b3 e3 + b4 e1 e2 - b5 e1 e3 + b6 e2 e3 +  b7 e1 e2 e3);    replaceall[    expand[x y],     power[e_, 2] /; first[characters[tostring[e]]] === "e" -> 1  ] 

this way have learned @edmund more elegant:

expand[(2 + e1)(3 + e2)] /.power[s_symbol,2]/; stringstartsq["e"]@symbolname[s]->1 
6 + 3 e1 + 2 e2 + e1 e2 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -