Message Boards Message Boards

3 Replies
0 Total Likes
View groups...
Share this post:

WorkingPrecision Default

Posted 11 years ago
I have read in a book that the control WorkingPrecision default is 16. Nevertheless when I have used the FindRoot  command as showed below with WorkingPrecision ->16 and without WorkingPrecision control I found different answers. I would like to know why.

In[118]:= FindRoot[Cos[100/x]==x/(x+1),{x,5000}]
    Out[118]= {x->5000.83}
    In[119]:= FindRoot[Cos[100/x]==x/(x+1),{x,5000}, WorkingPrecision->16]
    Out[119]= {x->5000.833191159525}

Thank You,
POSTED BY: Ana Squadri
3 Replies

I now know how find up to as many roots as I need to any precision I want. Instead of Reduce I have used SetPrecsion with NSolve however it will only solve 64 roots at a time with precision 30 so I have set up six NSolve lines and used the Join function to combine all the roots into one list each element with precision 30.

After a lot of trial and error I was actually able to use these roots in a generic trigonometric series.

There has to be an easier way. It's awkward to use. Again I've looked through the documentation and came up empty. My answer is in the attached Notebook.

I'm an oldtimer and had an easier time with Fortran with all due respect.

POSTED BY: Michael Bernthal
The default precision is what the computer uses for 64-bit floating-point arithmetic.
That turns out to be just UNDER 16 digits, because the precision is set by the
number of bits in the number, not a number of base-10 digits.

In[1]:= $MachinePrecision                                                             
Out[1]= 15.9546

In[2]:= N[Pi,16]                                                                      
Out[2]= 3.141592653589793

When you specify 16 digits for working precision, you tell FindRoot to use the high-precision
mechanism for calculations.

16 digits was the standard number for $MachinePrecision many years ago. The book might
be from that era, or is approximating.
POSTED BY: Bruce Miller
You're actually running into a number of items. First, Mathematica's default display setting shows 6 digits of precision. You can edit this by going to Edit->Preferences and then selecting the Advanced tab, then hitting the Option Inspector button. In the window that pops up, type precision. You can then edit the PrintPrecision directly. This is not, however, the underlying precision:
In[9]:= FullForm[FindRoot[Cos[100/x]==x/(x+1),{x,5000}]]

Out[9]//FullForm= List[Rule[x,5000.833191160513`]]
Here you see that 16 digits of numerical precision are underlying the result. However, you must also realize that those may not be real digits of precision. That is, when 16 digits determine the round-off location, the error can grow during the calculation.  Now let's look at the FullForm of your second calculation:
In[10]:= FullForm[FindRoot[Cos[100/x]==x/(x+1),{x,5000},WorkingPrecision->16]]

Out[10]//FullForm= List[Rule[x,5000.83319115952528306527469623136214642045`16.]]
Here, far more digits are kept but the result ends in `16, meaning Mathematica only trusts the first 16 digits of precision. 
POSTED BY: Jason Grigsby
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract