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]$
Hold@Evaluate@EXPR /. {Plus -> Times}
? $\endgroup$