# Strange behavior of Apart

Here is a piece of sad comedy based on some Apart behavior. Is there a way to make Apart do the expected step?

Consider a very simple expression, such as

expression = (a - b + c - d)/(a - b);


If we were to consider how to take this expression Apart to simplify it, I would argue that the simplest step that would come to mind is to write

1+(c - d)/(a - b)

cancelling the obvious a-b combination in numerator and denominator.

Now, let's see if Mathematica 11.3 on windows 10 would produce the same result?

expression//Apart


...crickets

• expression // Apart[#, a] & gives 1 + (c - d)/(a - b) – kglr Sep 17 at 23:27
• Moreover it looks as if chose d as the variable: In[4]:= Apart[expression, d] Out[4]= (a - b + c)/(a - b) - d/(a - b) – Chip Hurst Sep 17 at 23:32
• What it does will depend on the second argument. No second argument means you get what you get. – Daniel Lichtblau Sep 17 at 23:34
• confirming @Chip's observation: expression2 = (z - b + c - d)/(z - b); expression2 // Apart – kglr Sep 17 at 23:35
• Very interesting observations! Someone should post that the second argument is very important for Apart as an answer. – Kagaratsch Sep 18 at 0:30

Although it's not quite so obvious, Apart will always choose a variable when one isn't explicitly given.

Apart[(a - b + c - d)/(a - b), c]


$$\frac{c}{a-b}+\frac{a-b-d}{a-b}$$

vs

Apart[(a - b + c - d)/(a - b)]


$$\frac{a-b+c}{a-b}-\frac{d}{a-b}$$

and will choose in alphabetical inverse order which is the variable. (the last one in the alphabet. )

Apart[(a - b + d - s)/(a - b)]


$$\frac{a-b+d}{a-b}-\frac{s}{a-b}$$

Apart[(a - b + d - z)/(a - b)]


$$\frac{a-b+d}{a-b}-\frac{z}{a-b}$$

Except in this exactly same form but different variable case:

Apart[(z - b + d - s)/(z - b)]


$$\frac{d-s}{z-b}+1$$

...crickets