Message Boards Message Boards

Different results from two identical sums?

Posted 3 years ago

Hi all,

I wrote two different ways to compute some given sums and try to measure the time in order to pick the best, which saves a lot of computational time! I needed to do that because these sums require time which go from minutes to hours.

There are listed two methods, do not put too much attention in the math details, but what I compute and save in an output file they must be the same!

First of all, I set globally the precision on my notebook with the following line:

$PreRead = (# /. 
     s_String /; 
       StringMatchQ[s, NumberString] && 
        Precision@ToExpression@s == MachinePrecision :> s <> "`20." &);

Then what I compute is the quantity Den[c] for several values of parameter T=12, ... in both two methods. Starting with this value we see differences in the result of Den[c] in the two methods, but these differences are not smaller than the precision I set which is 20 digits! I thought that should be differences but of a number which is smaller than 10^{-20}! These differences are bigger than 10^{-16}, which is my tolerance number for 0 in double precision.

You can evaluate this notebook because the computation requires ~ 1 minute.

Please help me, I don't find any useful informations about it on the internet. If you need more other details or info please ask me!

Thank you so much, stay safe and have a good day!

POSTED BY: Nic Bat
2 Replies

Ciao Gianluca,

I don't know what is the reason of NumberString, I copied and pasted this line from the following discussion: "How to set the working precision globally? $MinPrecision does not work".

Link: https://mathematica.stackexchange.com/questions/38114/how-to-set-the-working-precision-globally-minprecision-does-not-work

Now I document myself on the scope of every function in this line.

Saluti, Nico

POSTED BY: Nic Bat

I don't know if it has anything to do with your problem, but I just discovered that NumberString does not always do what I would somehow expect:

In[2]:= StringMatchQ["1.2`20", NumberString]

Out[2]= False

In[11]:= StringMatchQ["3.13`",NumberString]

Out[11]= False
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract