Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

The two points are:

pts = {{1/4 (-1 - Sqrt[5]), Sqrt[5/8 - Sqrt[5]/8]}, 
       {1/4 (-1 - Sqrt[5]), -Sqrt[5/8 - Sqrt[5]/8]}};
EuclideanDistance @@ pts

N::meprec: Internal precision limit $MaxExtraPrecision = 50.` reached while evaluating 1/4 (-1-Sqrt[5])+1/4 (1+Sqrt[5]). >>

(* Sqrt[4 (5/8 - Sqrt[5]/8) + Abs[1/4 (-1 - Sqrt[5]) + 1/4 (1 + Sqrt[5])]^2] *)

According to the document, EuclideanDistance[u, v] equals to Norm[u - v], so it's not surprising that a Norm version generates the same warning and result:

Norm[Subtract @@ pts]

N::meprec: Internal precision limit $MaxExtraPrecision = 50.` reached while evaluating 1/4 (-1-Sqrt[5])+1/4 (1+Sqrt[5]). >>

(* Sqrt[4 (5/8 - Sqrt[5]/8) + Abs[1/4 (-1 - Sqrt[5]) + 1/4 (1 + Sqrt[5])]^2] *)

The warning disappears if we choose Sqrt:

Sqrt[Total[(Subtract @@ pts)^2]]

(* Sqrt[4 (5/8 - Sqrt[5]/8) + (1/4 (-1 - Sqrt[5]) + 1/4 (1 + Sqrt[5]))^2] *)

Why? Simply a bug?

share|improve this question
1  
No, not a bug. This is how Mathematica works. I think it is similar issue as this one mathematica.stackexchange.com/questions/31822/…. If you do this: $MinPrecision = $MachinePrecision; $MaxPrecision = $MachinePrecision; EuclideanDistance @@ pts the warning goes away. Mathematica needed more than 50 precision to decide on this one. That is all. You can also try $MaxExtraPrecision = Infinity; EuclideanDistance @@ pts but then you have to wait long time.... –  Nasser Sep 9 '13 at 4:39
    
see See wolfram.com/learningcenter/tutorialcollection/… page 20 for more discussion. –  Nasser Sep 9 '13 at 4:39
    
@Nasser I'm afraid that $MaxExtraPrecision = Infinity; won't work, at least it generates the warning General::nomem: The current computation was aborted because there was insufficient memory available to complete the computation. in my computer 囧. –  xzczd Sep 9 '13 at 6:38
    
Yes, same thing on my computer also, kernel actually crashed and I got an error message from C++ library. I did not say this will work, I said to try it :) –  Nasser Sep 9 '13 at 6:41
1  
@xzczd If numerics-based zero-testing of an expression (that is symbolically zero) fails to produce trustworthy result of zero or non-zero at some precision, it typically fails to do so at every level of precision. This is documented issue for $MaxExtraPrecision. –  kirma Sep 9 '13 at 6:49
add comment

1 Answer

up vote 5 down vote accepted

Mathematica produces this Message during evaluation of Abs[1/4 (-1 - Sqrt[5]) + 1/4 (1 + Sqrt[5])]. It seemingly tries to calculate approximate value of this expression using N although the user does not ask for this. Note that

Simplify[Unevaluated@Abs[1/4 (-1 - Sqrt[5]) + 1/4 (1 + Sqrt[5])]]

produces no error messages and gives correct result (0). Evaluation of 1/4 (-1 - Sqrt[5]) + 1/4 (1 + Sqrt[5]) does not produce any messages. So the reason is that Abs has some internal code which evaluates numerically some exact but complicated expressions, and it is showed in the "Possible issues" section on the Documentation page for Abs.

share|improve this answer
    
Oh… I should have check the document of Abs –  xzczd Sep 9 '13 at 6:14
1  
Also, you can attempt to redefine Abs -> (Abs[FullSimplify[#]] &) with a internals-overriding function such as withReplacedFunctions in my answer here. Nonetheless the warning is just a warning and (mostly) harmless - worst it does is leaving the subexpression unevaluated. –  kirma Sep 9 '13 at 6:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.