One part of a program I'm working on takes some angles and finds the largest angle out of the given angles and their complements. This usually works fine just by taking Max[angles, pi-angles], but when I tried angles coming from some parallelograms, I was often greeted with errors. A specific example is:

Internal precision limit $MaxExtraPrecision = 50.` reached while evaluating π - ArcCos[-(2/Sqrt[5])] - ArcCos[2/Sqrt[5]]"

From what I can tell, mathematica has trouble dealing with the fact that ArcCos[-(2/Sqrt[5])] = π - ArcCos[2/Sqrt[5]] and similar things.

I tried adding more precision with Block[{$MaxExtraPrecision = 90000}, code] but that didn't change anything.

In situations like this, how can I get it to just pick one of the maximal angles? (since they're equal, I don't care which one)

  • $\begingroup$ You will greatly increase your chances of getting help here if you were to put more effort into your question. If you have code that is not giving the results you want, show the code and describe exactly what you expected to get but didn't. Give the full set of inputs that produced the error message. $\endgroup$
    – m_goldberg
    Feb 16, 2017 at 7:02

1 Answer 1


There are some symbolic (i.e. exact) operations that use numerical evaluation under the hood. Max is one, but there are others too, e.g. try

Positive[π - ArcCos[-(2/Sqrt[5])] - ArcCos[2/Sqrt[5]]]

I believe that Max first compares the structure of the two expressions literally. If they are structurally identical, it just returns one. If they are not structurally identical, it attempts to evaluate both with sufficient precision to find a difference. The problem here is that while they don't look identical, there is no difference between them, mathematically speaking. It does not matter how many extra digits you allow, the two expressions will always be perfectly tied.

But since the system just does numerical evaluation with a finite number of digits, the fact that it found no difference so far is not a proof that there isn't one. And since Max is attempting an exact solution here, it will not settle for an approximation.

At this point, Mathematica is out of ideas, and simply gives up. Mathematica's way of indicating that is to return your input as it is. It means, "I cannot solve this."

What can you do in practice? Think about whether you really need an exact result. If an approximation is good enough for you, then compare inexact numbers, i.e. apply N manually to these expressions before compare them. Choose the number of digits that you require.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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