'How to multiply all terms of a fraction by something in sympy?

I have this equation:

u = -J/4 + (J*exp(-J*β) + bz*(-exp(bz*β) + exp(-bz*β)))/(exp(bz*β) + 1 + exp(-bz*β) + exp(-J*β))

The fraction part is this:

(J*exp(-J*β) + bz*(-exp(bz*β) + exp(-bz*β)))/(exp(bz*β) + 1 + exp(-bz*β) + exp(-J*β))

I'm trying to multiply the fraction by exp(-bz*β) in both the numerator and the denominator to get this exactly

u = -J/4 + (J*exp(-(J+bz)*β) + bz*(-1 + exp(-2*bz*β)))/(1 + exp(-bz*β) + exp(-2*bz*β) + exp(-(J+bz)*β))

How do I do it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source