Preserve the domain when simplifying a function (source code)

= Preserve the domain when simplifying a function

An algebraic simplification proves equality only where both original and transformed expressions are defined. If a cancelled factor vanishes at a point, the simplified expression may instead describe an extension to that point. For example,
$$
\frac1{1+\tan x}=\frac{\cos x}{\cos x+\sin x}
$$
holds only when $\cos x\ne0$ and $\cos x+\sin x\ne0$. The right side is zero at $x=\pi/2+k\pi$, but the left side is undefined there. A graph of the original <function> must retain those holes. The extension may be useful, but it is a different <function> with a larger <domain of a function>.