1
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ Replace[E^(mu beta)*(1/beta), beta -> 1/(k T), 2]? $\endgroup$
    – kglr
    Commented Apr 21, 2017 at 18:47
  • 1
    $\begingroup$ possible duplicate: mathematica.stackexchange.com/questions/71691/…, mathematica.stackexchange.com/questions/25538/… $\endgroup$
    – yohbs
    Commented Apr 21, 2017 at 18:48
  • $\begingroup$ 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? $\endgroup$ Commented Apr 21, 2017 at 19:01

1 Answer 1

4
$\begingroup$

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

$\endgroup$

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