Consider the following expressions:
a) $\;\dfrac{1}{x} - \dfrac{x}{x^2+1}$
b) $\;\dfrac{1}{x} + \dfrac{-x}{x^2+1}$
c) $\;\dfrac{1}{x} - \dfrac{x}{1 + x^2}$
d)$\;- \dfrac{x}{1 + x^2} + \dfrac{1}{x} $
They are all equivalent. In the book I'm reading, they are seemingly arbitrarily using all four forms above. As a programmer, it annoys me a lot because I think consistency is important and this book's authors are not being consistent.
So my question is if there are any math conventions which states which of the above four alternatives is the best to use? It there aren't and the answer is it depends, then what does it depend on?
Surely someone must have thought about this "problem" before?
E.g: No one would consider writing $x^2 + 1 + 2x^7 + x - x^3$. Instead, everyone thinks it should be $2x^7 - x^3 + x^2 + x + 1$. Why can't that thinking be applied to expressions other than polynomials?
There is no fixed convention. If an author makes any conscious decisions in this regard, they will be to present calculations in a form that makes them as easy to follow as possible, based on psychological considerations.
Consistency will often be a part of this, but consistency can mean different things in different situations. For example, in one case it might be advantageous to order the terms of a polynomial by increasing powers of $x$ (such as when you're interested in behaviour near $x = 0$), and in another by decreasing powers (for $x \to + \infty$).
In general, the ordering is frequently such that the important terms are placed at the beginning, and less important ones (for example terms that end up being negligible in some argument) near the end. But in other cases your main consideration may be to make some equality $A = B$ as obvious as possible by having corresponding terms in corresponding positions.
Of course, the considerations for computer algebra systems are likely to be completely different than those for human readers.