You have to use color_ONE() instead of just "1" where appropriate (terms of a sum must all be of the same type): ex g = (color_ONE()+eps*color_T(a)+pow(eps,2)*color_T(b)) * (color_ONE()-eps*color_T(c)+pow(eps,2)*color_T(d)); This will produce the right expression on expand().
Hi Christian, thanks for your reply. This is certainly a workaround, but I'm not too comfortable with it. My original problem occured in a user-defined algebra, I took the colour matrices only as an example. The question is what "expand()" should return for an expression like ( 1 + A ) * B where A and B are in some algebra. You say, that all terms of a sum must be of the same type, so that would involve to define a unit element in the algebra called for example "ONE" and write ( ONE + A ) * B instead. This works. But in this case I would think it's better if ( 1 + A ) * B throws an exception instead of just returning A*B. Otherwise you introduce a possible source of errors which is hard to track in complex programs. Stefan