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 Answers 2

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$
3
  • $\begingroup$ Yes, good idea. I had to replace 'n' by '{n}' in the table in Version 8. $\endgroup$
    – JHT
    Sep 20, 2018 at 18:28
  • $\begingroup$ Thanks, I was not aware of the `Defer´ command. $\endgroup$
    – JHT
    Sep 20, 2018 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, 2018 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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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