3
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

Like 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)

?

$\endgroup$
  • $\begingroup$ Yes, good idea. I had to replace 'n' by '{n}' in the table in Version 8. $\endgroup$ – fwgb Sep 20 '18 at 18:28
  • $\begingroup$ Thanks, I was not aware of the `Defer´ command. $\endgroup$ – fwgb Sep 20 '18 at 18:30
  • $\begingroup$ @fwgb you can use 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$ – Kuba Sep 20 '18 at 18:34
1
$\begingroup$
exp = -(1/2) + (3 x^5)/2;

Block[{Power = (Inactive[Times] @@ Table[#, #2] &) }, exp] (* or *)
exp /. Power -> (Inactive[Times] @@ Table[#, #2] &)

both give

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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