5

I have a bunch of expressions like this one:

$\frac{e^{-\frac{7 J}{2 k T}} \left(2 e^{-\frac{2 g H \mu _B}{k T}}+e^{-\frac{g H \mu _B}{k T}}-e^{\frac{g H \mu _B}{k T}}-2 e^{\frac{2 g H \mu _B}{k T}}\right)+e^{\frac{5 J}{2 k T}} \left(3 e^{-\frac{3 g H \mu _B}{k T}}+2 e^{-\frac{2 g H \mu _B}{k T}}+e^{-\frac{g H \mu _B}{k T}}-e^{\frac{g H \mu _B}{k T}}-2 e^{\frac{2 g H \mu _B}{k T}}-3 e^{\frac{3 g H \mu _B}{k T}}\right)}{e^{-\frac{7 J}{2 k T}} \left(e^{-\frac{2 g H \mu _B}{k T}}+e^{-\frac{g H \mu _B}{k T}}+e^{\frac{g H \mu _B}{k T}}+e^{\frac{2 g H \mu _B}{k T}}+1\right)+e^{\frac{5 J}{2 k T}} \left(e^{-\frac{3 g H \mu _B}{k T}}+e^{-\frac{2 g H \mu _B}{k T}}+e^{-\frac{g H \mu _B}{k T}}+e^{\frac{g H \mu _B}{k T}}+e^{\frac{2 g H \mu _B}{k T}}+e^{\frac{3 g H \mu _B}{k T}}+1\right)}$

and I want to convert all the terms inside the parentheses, and not the terms outside, into hyperbolic trig functions, using ExpToTrig command, but I'm not sure how to do this. Any help would be really appreciated.

snowball
  • 207
  • 1
  • 4

1 Answers1

7
x = E^-n (2 E^-1 + E^2) + E^n (2 E^-2 + E);

x /. Times[a_, b_] :> Times[a, ExpToTrig@b]

E^n (E + 2 Cosh[2] - 2 Sinh[2]) + E^-n (2 Cosh[1] + Cosh[2] - 2 Sinh[1] + Sinh[2])

eldo
  • 67,911
  • 5
  • 60
  • 168
  • You beat me to it. (+1) – rcollyer Aug 11 '14 at 14:18
  • Awesome! Thank you! – snowball Aug 11 '14 at 14:27
  • Thanks for acceptance @snowball. In cases like this one you should look at the FullForm of a simplified example (first line of my answer) to find the appropriate replacement pattern. For other, more complex cases, read f.e. http://mathematica.stackexchange.com/questions/56975/replacing-a-sum-of-expressions/56989#56989 – eldo Aug 11 '14 at 19:02