Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
Closely related: What's the correct method to simplify exponentials? –  Artes Aug 11 at 14:05

1 Answer 1

up vote 7 down vote accepted
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])

share|improve this answer
    
You beat me to it. (+1) –  rcollyer Aug 11 at 14:18
    
Awesome! Thank you! –  snowball Aug 11 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. mathematica.stackexchange.com/questions/56975/… –  eldo Aug 11 at 19:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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