(I suspect this question is a duplicate, but I didn't find a sufficiently similar question with an answer to it.)
I'm having trouble with comparisons of symbolic Reals that are equal, but which Mathematica has trouble recognising them as equal, apparently because it uses N to compare these (apparently after some simple symbolic manipulation). Typically these issues creep up in conditions like one (greatly simplified) below:
x > y /. {x -> Sqrt[(2 - Sqrt[3])^2 + (-3 + 2*Sqrt[3])^2], y -> 4 - 2*Sqrt[3]}
N::meprec: "Internal precision limit $MaxExtraPrecision = 50.` reached while evaluating -4+2\ Sqrt[3]+Sqrt[(2-Sqrt[3])^2+(-3+2 Sqrt[3])^2]."
Sqrt[(2 - Sqrt[3])^2 + (-3 + 2*Sqrt[3])^2] > 4 - 2*Sqrt[3]
This is in no way undocumented feature; it is discussed under Possible Issues section of $MaxExtraPrecision.
What I really want is Mathematica to try a bit harder on solving these (in)equalities numerically in a block of code. How do I accomplish this? As a workaround for specific problem above, this does work (while Simplify on inequality part doesn't):
x > y /. Simplify @ {x -> Sqrt[(2 - Sqrt[3])^2 + (-3 + 2*Sqrt[3])^2], y -> 4 - 2*Sqrt[3]}
False
I would be happy to see a solution that could wrap up around a block of code, and which could possibly work also on non-algebraics that FullSimplify can handle.
EDIT:
To clarify my question: I want first example to evaluate like the expression below, and in general Greater to evaluate for NumericQ argument list similarly inside a code block where I want this feature to be used:
Simplify[Sqrt[(2 - Sqrt[3])^2 + (-3 + 2*Sqrt[3])^2]] > Simplify[4 - 2*Sqrt[3]]
False
Nappears only in the error message, not in my code. This is exactly the inconvenience I'm trying to get rid of. – kirma Sep 07 '13 at 09:31MachinePrecisiononly to be able to compare things with Matlab and Fortran when I want to. You can force all computation to be inMachinePrecisionby putting this at the top of the notebook or in your init.m$MinPrecision = $MachinePrecision; $MaxPrecision = $MachinePrecision;Now your example runs with no warnings:Lesstry a bit more in symbolic manner, and return unevaluated if it's indecisive, instead of providing a possibly wrong result through limited-precision numeric evaluation. – kirma Sep 07 '13 at 09:37PossibleZeroQ, withMethod -> "ExactAlgebraics". This post Most efficient way to determine conclusively whether an algebraic number is zero discusses the issue. – Artes Sep 07 '13 at 09:38PossibleZeroQand"ExactAlgebraics". :)What I'd wish here would be a similar "knob" for functions like
– kirma Sep 07 '13 at 09:42Less; apparently it isn't present directly. Something that'd pre-evaluateSimplifyfor all arguments of these comparison functions before performing them.InfinityandIndeterminatebehave differently to IEEE infs and NaNs. While disabling the tolerance is possible in our own routines, for users it's hard to know where it's applied internally, hence where and when an error (versus strict IEEE arithmetic) of up to 7 ULPs might be able to accumulate. In fact, knowing what is done with a library call or using (potentially mixed precision) bignum arithmetic is difficult in itself. By saying it is not fully IEEE-compliant – Oleksandr R. Sep 10 '13 at 14:46