# How do you multiply out integer powers in a symbolic expression?

I have the following problem:

I want to transform integer powers into a series of multiplications within symbolic expressions. E.g. x^3 should be written as x*x*x. I tried applying the rule a_^b_ -> a a^b-1 with a ReplaceRepeated, but Mathematica "simplifies" this again to x^3.

Any suggestions?

-
You could use NonCommutativeMultiply, or any other inert head for your intermediate representation of powers as products, and convert back at the end, when you need it. – Leonid Shifrin Jan 24 '13 at 17:31

## 1 Answer

x^3 //. (a_)^(b_) -> HoldForm[a]*a^(b - 1)


x^3 + 2*x^2 - 3*x + x*y^2 + y^3*x^5 //. (a_)^(b_) ->  HoldForm[a]*a^(b - 1)


-
Can you explain that behavior? – Stefan Jan 24 '13 at 19:33
@Stefan What behavior? Have you checked the HoldForm doc page? – Sjoerd C. de Vries Jan 24 '13 at 19:54
yes I did but would still not come to your solution. I just find yours pretty interesting. Sorry bothering you. – Stefan Jan 24 '13 at 19:57
@Stefan There's no bothering, don't get me wrong. I'm just trying to find out the source of your apparent puzzlement. You can consider HoldForm as Hold with a cloacking device. Does that help? – Sjoerd C. de Vries Jan 24 '13 at 20:05