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
Larger values of $MaxExtraPrecision
only made the computation take longer before it failed.
Could there be something wrong with the algorithm used to compute a difference to high precision in the case where the two terms are essentially the identical?
Edit
From the first answer posted, I realize I should ask my question more carefully. I am not sure how Mathematica estimates the precision of very small numbers, which can be a tricky business. Perhaps, that's my problem. For a difference that is expected to be zero or very close, should I be asking for evaluation in terms of accuracy rather than precision?
I note that
N[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] - root[1], {∞, 1000}]
returns 0.*10^-1001
with no error message. For this return value, I get
Accuracy[0.*10^-1001]
1000.
Precision[0.*10^-1001]
0.
This is consistent with the behavior that bothers me, but why is the precision zero?
WRI defines precision and accuracy as follows:
Precision[x]: the total number of significant decimal digits in x
Accuracy[x]: the number of significant decimal digits to the right of the decimal point in x
In my mind, these definitions are not consistent with the accuracy and precision values shown above. The definitions imply that accuracy will always be less than precision.
Root[1]
andRoot[1 + 6 #1 - ... &, 5]
: applyingMinimalPolynomial
to both of these yields the same expression. Equivalently, applying Root[MinimalPolynomial[#], 1]& to their difference--rather thanN
--produces $0$ (and you can just as easily check that this is the only root). $\endgroup$