Expansion of algebraic expressions