Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
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 1

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

Mathematica graphics

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

Mathematica graphics

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.