Reputation: 61026
I have a nice polynomial, which is in fact the non-posted answer to this question (I guess it is homework, so I'll post nothing until the asker shows some brain activity :D ):
jj = 1 + 54 #1 + 855 #1^2 + 6300 #1^3 + 37296 #1^4 + 221706 #1^5 +
385782 #1^6 + 1899783 #1^7 - 713709 #1^8 - 8772909 #1^9 +
1718343 #1^10 + 17264169 #1^11 - 3659847 #1^12 - 20026899 #1^13 +
3423276 #1^14 + 13768320 #1^15 - 1610712 #1^16 - 5314050 #1^17 +
881651 #1^18 + 1545093 #1^19 - 151263 #1^20 - 298626 #1^21 -
24552 #1^22 + 21978 #1^23 + 6594 #1^24 + 792 #1^25 +
45 #1^26 + #1^27 &
I want the first root. Just checking:
p[f_] := Plot[f[t], {t, Root[f, 1] - .003, Root[f, 1] + .003}];
p[jj]
Seems steep but good. But look now:
In[394]:= N[jj[Root[jj, 1]]]
Out[394]= -2.9523*10^13
If I ask for some precision:
In[396]:= N[jj[Root[jj, 1]], 1]
During evaluation of In[396]:= N::meprec: Internal precision limit $MaxExtraPrecision = 50.` reached while evaluating 1+<<11>>+<<18>>. >>
Out[396]= 0.*10^-49
So the question is ... How different is the precision managing in Mma when you ask for a Plot and when you ask for a numeric result?
Upvotes: 1
Views: 1743
Reputation: 5681
The problem is making a distinction between absolute and relative accuracy. Rant below, but first the solution:
According to the docs for AccuracyGoal
and PrecisionGoal
, Mathematica will strive to return the result x
with a numerical error less than 10^{-a} + 10^{-p} Abs[x]
where a
is AccuracyGoal
and p
is PrecisionGoal
. This causes a problem, if specifying a PrecisionGoal
for a zero result. Solution: only specify AccuracyGoal
.
For N
you do this by giving a Precision,Accuracy
tupple:
In[113]:= N[jj[Root[jj,1]],{0,24}]
Out[113]= 0.*10^-24
<rant> The use of the terms "accuracy" and "precision" in Mathematica is very sloppy. They should really be called "absolute accuracy" and "relative accuracy". See e.g. Wikipedia for a discussion of the correct terminology.</rant>
Upvotes: 4
Reputation: 4964
Well, I don't think the computations performed by your plot command are anything like those performed by your N command. You can check what points are plugged in during the plotting using Reap and Sow:
p[f_] := Plot[f[t], {t, Root[f, 1] - 0.003, Root[f, 1] + 0.003},
EvaluationMonitor -> Sow[t]];
Reap[p[jj]][[2, 1]]
Notice that Plot uses only machine precision numbers. This is very different from your N command, where you are plugging in the exact root of the function. The difficulty with your arbitrary precision computation arises since you're trying to estimate an exact zero and Mathematica is unable to attach a precision to the result. This can happen with much simpler polynomials.
x0 = x /. First[Solve[x^5 - x - 1 == 0, x]];
N[x0^5 - x0 - 1, 9]
Upvotes: 2
Reputation: 26910
The precision of the plot is just (approx.) the same as the graph size/resolution. This is an optimization in Mathematica.
Upvotes: -2