# Simplify oversimplifies. What to do about it?

According to Mathematica 10: $$\mbox{Simplify}\left[\frac{\frac{1}{t^2}-1}{(t+\frac{1}{t})^2}\right]==\frac{1-t^2}{(1+t^2)^2}$$

However, the first equation does not tolerate $t=0$ because of a division by zero, but the second equation cleary does allow $t=0$.

How come and what can I do to avoid this?

Raw input:

f[t_] = (1/t^2 - 1)/(t + 1/t)^2
FunctionDomain[f[t], t]
g[t_] = Simplify[f[t]]
FunctionDomain[g[t], t]


Thanks!

• The singularity of the first expression is removable at $t=0$, taking value $1$. Unless you're really nitpicking, the simplification is everywhere correct, and it's only incorrect in the sense that a removable singularity has been removed. – Patrick Stevens Aug 5 '15 at 20:03
• You'll find this sort of limitation in pretty much every computer algebra system. First check FunctionDomain for a potential workaround, then here and here. I would consider this a duplicate of these question (there are more on the same topic). – Szabolcs Aug 5 '15 at 20:05

I'm not sure how well this works for more complicated expressions, but my idea is as follows:

Using the option ComplexityFunction. If the domain of an intermediate expression is larger than the original expression, assign a very large penalty. Add this to Mathematica's default complexity function (SimplifySimplifyCount).

(* define domain for readability *)
domain[e_, x_] := FunctionDomain[e, x, Complexes, Method -> {"Reduced" -> False}]

CarefulSimplify[expr_, x_, r___] := With[{dom = domain[expr, x]},
Simplify[expr, r,
ComplexityFunction -> (SimplifySimplifyCount[#] +
10^20 Boole[!TrueQ[PossibleZeroQ[expr - #] &&
Reduce[Equivalent[dom, domain[#, x]]]]]&)
]
]


For your example this works, but again I haven't tried this for more complicated expressions.

CarefulSimplify[(1/t^2 - 1)/(t + 1/t)^2, t]

(-1 + 1/t^2)/(1/t + t)^2


Edit: I've incorporated Karsten 7.'s idea, since otherwise we're calling Reduce more than we need to.

• Or one might use Method -> {"Reduced" -> False} instead of Complexes or no third argument. – Karsten 7. Aug 6 '15 at 2:21