Let an expression like -(1/2) + (3 x^5)/2
be given.
How can this be turned into -(1/2) + (3 x x x x x)/2
?
All powers of x
shoud be decomposed into product form.
I tried using /.Power[]
and Hold[]
but this is tricky.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityLike this:
Defer[-(1/2) + (3 x^5)/2] /. x_^n_?Positive :> RuleCondition@Table[x, n] /. List -> Times
-(1/2)+3/2 (x x x x x)
?
HoldForm
too, depends of how long you want to keep it held. Defer is gone now so another evaluation will bring x^5
back.
$\endgroup$
exp = -(1/2) + (3 x^5)/2;
Block[{Power = (Inactive[Times] @@ Table[#, #2] &) }, exp] (* or *)
exp /. Power -> (Inactive[Times] @@ Table[#, #2] &)
both give