# why is there an unsimplified 0 term in an evaluated expression? [duplicate]

Is this behavior long-standing? Expected?

Simplify[0. + 1. z, z > 0]  (*-> 0.+1.z *)


I'm using Mma 11.1. I do not recalling seeing this behavior before. (Bad memory?) It shows up all over the place. E.g.,

eq1 = 2.0 x == y
eq2 = x + y == z
Solve[eq1 && eq2, {x, y}, Reals]


produces

{{x -> 0. + 0.333333 z, y -> 0. + 0.666667 z}}


Why are the zero terms (often) not simplified away?

• Approximate zero 0. is not simplified away because it does not represent an exact zero 0. It keeps the Precision of the equation MachinePrecision, no matter what happens to the other terms. You can use Chop to get rid of it, if desired. (Take care to use an appropriate tolerance.) – Michael E2 Jun 7 '17 at 22:47
• Related: (6994) – Mr.Wizard Jun 8 '17 at 2:01

### Edit

The behavior you discuss in your question has been around as long as I have been using Mathematica. As Michael E2 writes in his comment to the question it results from using inexact quantities in expressions.

Perhaps the following simple function would be of use to you.

fixup[expr_] := expr /. u_ /; Sign[u] == u :> Sign[u]


Example of use

fixup[0. + 1. z]


z

fixup[(0. + 1. z)/(0. + 2. z)^2]


0.25/z

 fixup[{{x -> 0. + 0.333333 z, y -> 0. + 0.666667 z}}]


{{x -> 0.333333 z, y -> 0.666667 z}}

• Shorter: fixup[expr_] := expr /. u_ /; u == 0 || u == 1 :> Round[u] – Mr.Wizard Jun 8 '17 at 1:57