# Substituting variables in only certain environments? [duplicate]

I was integrating a function and got something essentially like

E^(mu beta) * (1/beta)


There beta is defined as 1/(kT). I want to display the entire expression as

E^(mu beta) * (k T)


Is there a non-manual way to do that?

• Replace[E^(mu beta)*(1/beta), beta -> 1/(k T), 2]? – kglr Apr 21 '17 at 18:47
• – yohbs Apr 21 '17 at 18:48
• Thanks! It is the duplicate of the first question you linked, although not the second. Is there a way to let this question display that correct existing question so that I could mark this question as resolved? – Rethliopuks Apr 21 '17 at 19:01

E^(mu beta)*(1/beta) /. {u : mu beta -> u, beta -> 1/(k T)}