I have stumbled across some weird behaviour with Apart.
ans1 = Apart[(x1/r2 + x2/r1)/(1/r1 + 1/r2)]
Gives
(r1 x1)/(r1 + r2) + (r2 x2)/(r1 + r2)
But
ans2 = Apart[(b1/r2 + b2/r1)/(1/r1 + 1/r2)]
Despite being logically equivalent to ans1 gives
b2 + (b1 r1 - b2 r1)/(r1 + r2)
So, depending on the alphabetic letter of the variable i.e. x1, x2 versus b1, b2, Mathematica behaves differently. The two solutions are mathematically equivalent.
Apart[ans2 /. {b1 -> x1, b2 -> x2}]
Gives
(r1 x1)/(r1 + r2) + (r2 x2)/(r1 + r2)
But the behaviour just seems really counterintuitive. Note that if I use y1 and y2, I get the same behaviour as x1 and x2. But for any other letter of the alphabet I use so far (not tried all), I get the behaviour of b1 and b2.
Hopefully I am missing something obvious, but I cannot understand why the letter of the alphabet given to a variable should alter Mathematicas behaviour.
varin the call. See help. So to get same output doApart[(x1/r2 + x2/r1)/(1/r1 + 1/r2), x1]andApart[(b1/r2 + b2/r1)/(1/r1 + 1/r2), b2]otherwise Mathematica picks the main var for you using some internal ordering. May be lexicographic letter ordering. From help onvarit saystreats all variables other than var as constants.– Nasser Mar 03 '22 at 17:33Sort). Consequently, the canonical order of the variables used can affect the performance of internal algorithms and the subsequent form of output. – Bob Hanlon Mar 03 '22 at 18:13xvs.a. As for that second argument, partial fraction decompositions are at heart a univariate operation. If you don't pick which is the variable, Mathematica will pick one for you based on which it first encounters in putting the rational function into an internal form. This might or might not correspond to the first symbol you see. – Daniel Lichtblau Mar 03 '22 at 23:17Simplify. Quoting from the documentation (Simplify->Possible Issues): "Results of simplification may depend on the names of symbols:Simplify[(1 - a^2)/b^2, a^2 + b^2 == 1]⟹1;Simplify[(1 - c^2)/b^2, c^2 + b^2 == 1]⟹(1 - c^2)/b^2" In the latter case, providing the variable names in reverse lexical order preventsSimplifyfrom finding a solution, and it thus returns what you entered. You get the same behavior withSimplify[(1 - b^2)/a^2, b^2 + a^2 == 1]. I.e., it doesn't appear to be about... – theorist Mar 04 '22 at 09:23