Simplifying a term to achieve a certain result

Run the following code

(5/x - 7/(x + 1)) ((x + 1) - x)

This result is expected because ((x + 1) - x) simplifies to 1.

5/x - 7/(1 + x)

But I was expecting this result as following instead.What’s the code implementation for this?

-12 + (7 x)/(1 + x) + (5 (1 + x))/x

I don’t think you can enter
(5/x - 7/(x + 1)) ((x + 1) - x)
and keep ((x + 1) - x) from evaluating to 1. So you’ll have to enter or evaluate some other expression.

Of course, if it’s allowed to enter something else, then entering -12 + (7 x)/(1 + x) + (5 (1 + x))/x will evaluate to the desired expression. This suggestion probably seems flip, but if something different is to be entered, I am far from understanding what differences are allowed and what differences are prohibited. Any help?

I also do not understand what sequence of algebraic operations you have mind that lead from (5/x - 7/(x + 1)) ((x + 1) - x) to -12 + (7 x)/(1 + x) + (5 (1 + x))/x. I could probably reverse-engineer something if I thought long and hard. Frankly, though, I don’t think it’s worth my time, when you probably already have something in mind that you could share.

This might be a good start: Inactivate[(5/x - 7/(x + 1)) ((x + 1) - x)]. Then you might be able to perform the structural operations you have mind. When done, then apply Activate[] to the transformed expression.

Gee, I accidentally I discovered it:

foo = Inactivate[(5/x - 7/(x + 1)) ((x + 1) - x)]
Distribute[foo, Inactive@Plus, Inactive@Times] // Activate

This does what you want:

Apart[(5/x - 7/y) (y - x)] /. y -> x + 1

The operation involves treating
(
x
+
1
)
(x+1) and
x
x as separate entities and multiplying each with the terms inside the other parentheses, rather than computing
(
x
+
1
−
x
)
(x+1−x) first—which is how your code implements it. Thank you very much!

I want to generalize this computational process so that when the expression is changed, the same operational rules still apply.