# How do I hold the form of terms in an output?

Consider the following expression:

EXPR = Map[Simplify@Exp[#] &, b Log[f[t]] + a (Log[f[t]] - Log[g[t]]) - c Log[g[t]]]


whose output is:

$f(t)^a g(t)^{-a}+f(t)^b+g(t)^{-c}$

I want to replace the all the additions with multiplications, while otherwise retaining the form of the output. I.e., I want to hold the form of each individual term in the output of EXPR, so as to obtain:

$f(t)^a g(t)^{-a} f(t)^b g(t)^{-c}$

I need to hold the forms of the terms to obtain the desired output, because once I change the additions to multiplications MMA automatically combines the terms:

EXPR/. {Plus -> Times}


$f(t)^{a+b} g(t)^{-a-c}$

So I instead tried this, which doesn't work because it's following the standard behavior for Hold and thus outputting each "EXPR[[i]]" verbatim, rather than outputting each EXPR[[i]] and holding its respective form.

Product[Hold@EXPR[[i]], {i, 1, Length[EXPR]}]


$\text{Hold}[\text{EXPR}[[i]]]^3$

Finally, these approaches (both of which give the same output) do hold the form of each term in EXPR's output, but surround each with extraneous Hold[] syntax.

Product[Hold@Evaluate@EXPR[[i]], {i, 1, Length[EXPR]}]
Product[Hold[#] &[EXPR[[i]]], {i, 1, Length[EXPR]}]


$\text{Hold}\left[f(t)^b\right] \text{Hold}\left[g(t)^{-c}\right] \text{Hold}\left[f(t)^a g(t)^{-a}\right]$

• Do you need this because the multiplication is non-commutative? Or is there another goal here? Aug 17 '18 at 22:50
• No, it's purely a formatting issue. The question was motivated by my attempt to answer this question: mathematica.stackexchange.com/questions/180127/… I've gotten close, but the next step is replacing the additions with multiplications, while otherwise holding the form. More generally, it made me curious whether there was a way to apply Hold/HoldForm/Unevaluated, etc. to parts of an expression's output, as opposed to the input expression itself, should I encounter future cases where that type of manipulation is useful. Aug 17 '18 at 22:59
• Hold@Evaluate@EXPR /. {Plus -> Times}? Aug 18 '18 at 16:43

You can change the head of EXPR to Inactive[Times]:
Inactive[Times] @@ EXPR

EXPR /. Plus ->Inactive[Times]