6

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!

yohbs
  • 7,046
  • 3
  • 29
  • 60
GambitSquared
  • 2,311
  • 15
  • 23
  • 3
    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 05 '15 at 20:03
  • 1
    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 05 '15 at 20:05

1 Answers1

7

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 (Simplify`SimplifyCount).

(* 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 -> (Simplify`SimplifyCount[#] + 
      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.

Greg Hurst
  • 35,921
  • 1
  • 90
  • 136