1

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?

yohbs
  • 7,046
  • 3
  • 29
  • 60
Rethliopuks
  • 289
  • 1
  • 6
  • Replace[E^(mu beta)*(1/beta), beta -> 1/(k T), 2]? – kglr Apr 21 '17 at 18:47
  • 1
    possible duplicate: https://mathematica.stackexchange.com/questions/71691/replace-expression-but-only-outside-of-a-function, https://mathematica.stackexchange.com/questions/25538/substitution-rules-excluding-subscripted-variables – 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

1 Answers1

4

One useful trick is to precede the rule with an identity rule matching the part that you don't want to change. For example

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

This is obviously more useful in dealing with larger expressions

mikado
  • 16,741
  • 2
  • 20
  • 54