Adding two numbers of high precision results in a number of low precision??
- To: mathgroup at smc.vnet.net
- Subject: [mg56887] Adding two numbers of high precision results in a number of low precision??
- From: Kees van Schaik <schaik at math.uni-frankfurt.de>
- Date: Mon, 9 May 2005 01:46:09 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi, I have the following question. In a pretty long code (so I won't send everything) at some point the following loop occurs: > For[i=1,i<=3,i++, > bTemp[i,0,j]=bTemp[i,0,0]+Q[i,j]; > Print["Precisie bTemp[",i,",0,0] = ",Precision[bTemp[i,0,0]]]; > Print["Precisie Q[",i,",",j,"] = ",Precision[Q[i,j]]]; > Print["Precisie bTemp[",i,",",0,",",j,"] = ",Precision[bTemp[i,0,j]]]; > ]; (* einde For *) ("Precisie" is Dutch for "precision" ;)), where the j is a loop counter and the Q[.,.]'s and bTemp[.,0,0]'s are known numbers of a certain precision. Now two pieces of the output of this piece of code look like this: > Precisie bTemp[2,0,0] = 397.142 > Precisie Q[2,1] = 397.172 > Precisie bTemp[2,0,1] = 395.193 and > Precisie bTemp[3,0,0] = 389.685 > Precisie Q[3,1] = 390.729 > Precisie bTemp[3,0,1] =53.8232 Now the first one makes sense, but the last one, how is it possible that if I add two numbers of precision ca. 390 I get something of precision 53 back? I hope somebody could explain, because there are numerical problems in my code that mess things up and I'm afraid the stuff above could have to do with it... Thanks in advance & best wishes, Kees van Schaik -- ==================================================== Kees van Schaik Frankfurt MathFinance Institute J.W. Goethe-Universitaet Frankfurt am Main Tel: +49 (0)69 79823453 WWW: http://ismi.math.uni-frankfurt.de/vanSchaik/ ====================================================