# Can some one explain perplexing behavior of arbitrary precision arithmetic?

I was exploring the problem presented by another question, when I ran into some behavior of Mathematica's arbitrary precision arithmetic engine that perplexes me.

Here is what I was doing

poly = 64 x^7 - 112 x^5 - 8 x^4 + 56 x^3 + 8 x^2 - 7 x - 1;
solns = Solve[poly == 0, x, Reals]


{{x -> -(1/2)}, {x -> 1},
{x -> Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 1]},
{x -> Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 2]},
{x -> Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 3]},
{x -> Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 4]},
{x -> Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5]}}

root[n_] := Cos[2 n Pi/11];
poly == 0 /. x -> root[1]


True

N[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] == root[1], 20]


True

N[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] - root[1], 20]


N::meprec: Internal precision limit $MaxExtraPrecision = 50. reached while evaluating -Cos[(2 [Pi])/11]+Root[1+6 #1-12 #1^2-32 #1^3+16 #1^4+32 #1^5&,5,0]. 0.*10^-70 PossibleZeroQ[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] - root[1]]  PossibleZeroQ::ztest1: "Unable to decide whether numeric quantity -Cos[(2\[Pi])/11]+Root[1+6\ #1-12\ #1^2-32\ #1^3+16\ #1^4+32\ #1^5&,5,0] is equal to zero. Assuming it is." True It would appear that Mathematica can compare the values of Root[1+6 #1+..+32 #1^5&,5] and root[1] more easily than it can determine their difference. I realize differences lose precision very rapidly, but I still find this perplexing. Finally I tried raising the value of $MaxExtraPrecision, but still no joy.

Block[{$MaxExtraPrecision = 10000}, N[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] - root[1], 20]]  N::meprec: "Internal precision limit$MaxExtraPrecision = 10000. reached while evaluating -Cos[(2\[Pi])/11]+Root[1+6\ #1-12\ #1^2-32\ #1^3+16\ #1^4+32\ #1^5&,5,0]"

0.*10^-10020

## 1 Answer

The exact equality comparison returns unevaluated.

Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] == root[1]

(* Out[900]=
Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] ==
Cos[(2 \[Pi])/11] *)


The numerical values agree to all significant digits.

N[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5], 20]

(* Out[902]= 0.84125353283118116886 *)

N[root[1], 20]

(* Out[903]= 0.84125353283118116886 *)


This should explain why the numerical comparison gave True.

As for the max precision stuff, notice that you cannot get any precision in the difference since they are in fact equal. This not being something mathematica detects, it keeps ramping precision in an effort to get some actual digits.

You might instead tell N to give 20 digits of Accuracy (in the Mathematica meaning of that term). Then it will give up once it has attained 20 correct digits to the right of the decimal point.

N[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] -
root[1], {Infinity, 20}]

(* Out[906]= 0.*10^-20 *)


Also note that you can convert root[1] to the algebraic form using RootReduce.

RootReduce[root[1]]

(* Out[919]= Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] *)


All that said, I'm not sure if I have addressed your question. I gather you think something incorrect is happening. But I'm not clear on what that perceived something is, and moreover I'm confident nothing inappropriate is in fact taking place in the computations you show.

-