Re: Re: Two questions (1) Sollve and (2) Precision

*To*: mathgroup at smc.vnet.net*Subject*: [mg67086] Re: [mg67051] Re: [mg67035] Two questions (1) Sollve and (2) Precision*From*: "Carl K. Woll" <carlw at wolfram.com>*Date*: Fri, 9 Jun 2006 01:07:20 -0400 (EDT)*References*: <200606070910.FAA23549@smc.vnet.net> <4486F6B4.5070905@wolfram.com> <200606080853.EAA12260@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Bharat Bhole wrote: > Dan, thanks very much for your response. The first one is clear now, but I > still have a question with the second one. Please let me know if I am > incorrect in the following interpretation. > Paraphrasing Daniel Lichtblau's response slightly, note that your coefficient matrix is ill-conditioned (where I suppress the error message): In[6]:= LUDecomposition[{{64919121, -159018721}, {41869520.5, -102558961}}] // Last Out[6]= 8.32857Ã?10^16 LUDecomposition returns the condition number as its last argument. A condition number of ~10^16 indicates that no correct digits are likely to be returned by Solve using machine precision. > If as you have said, the difference is checked to 16 digits in case of a > machine precision number and 50 digits in the case where precision is set to > 50, then should I not see at most something like *-729335 x* *10^(-16),* or > something smaller than that. You are confusing Precision and Accuracy here. Think of Precision as the number of digits of the Mantissa when written in scientific notation, and Accuracy as the number of digits of the number to the right of the decimal when written in decimal notation. Carl Woll Wolfram Research > Even with higher precision at least the first 16 digits should be the same > as the exact number (especially, since they are the same with less precise, > machine precision number). > > Thanks, > Bharat. > > > > >>>In[2]: 123456789123 * 123456789123.0 > > >>>Out[2]: 1.52416 =D7 10^22 > > > Out[2] is a machine-precision number. > > > >>> In[3]:SetPrecision[ 123456789123 * 123456789123.0 , 50 ] >>> Out[3]: 1.5241578780560891838464000000000000000000000000000 x 10^22 > > > Out[3] has greater precision than the machine precision number. > > Why should Out[3] be farther than the exact number? > > > On 6/7/06, Daniel Lichtblau <danl at wolfram.com> wrote: > >>Bharat Bhole wrote: >> >>>Would appreciate if someone can point out why Mathematica is not giving >> >>the >> >>>expected output in the followng two cases. >>> >>>(1) I was trying to solve the follwing two linear equations using >> >>'Solve'. >> >>> >>>*In: Solve[{64919121*x-159018721*y=8A1,41869520.5*x-102558961*y=8A0 >> >>},{x,y}]* >> >>>*Out: {}* >>> >>>However, the solution exists and is given by x = 205117922, y = >> >>83739041 >> >>>Why is Mathematica unable to solve this simple linear equation? Am I >> >>doing >> >>>something wrong? >> >>You are using machine precision inputs. The coefficient matrix has a >>linear dependency to machine precision. You might instead do: >> >>Solve[{64919121*x-159018721*y==1, >> (41869520+1/2)*x-102558961*y==0}, {x,y}] >> >> >> >>>(2) I suppose that the default precision for numerical calculations is >>>MachinePrecision which is less than 16. If I increase the precision, >> >>should >> >>>I not get more accurate results? The example below seems to contradict >> >>that. >> >>>(i) Exact Calculation >>> >>>*In[1]: 123456789123 * 123456789123* >>> >>>*Out[1]: 15241578780560891109129* >>> >>>(ii) Numerical Calculation with Default Precision >>> >>>*In[2]: 123456789123 * 123456789123.0* >>> >>>*Out[2]: 1.52416 =D7 10^22* >>> >>>(iii) Numerical Calcuation with a higher precision. >>> >>>*In[3]:SetPrecision[ 123456789123 * 123456789123.0 , 50 ]* >>> >>>*Out[3]: 1.5241578780560891838464000000000000000000000000000 x 10^22* >>> >>>Now if I calculate Out[1]-Out[2], I get zero. >> >>The difference is only checked to machine precision. If you think about >>it you quickly realize one cannot possibly get more information out of >>In[2] than that. >> >> >> >>>But if I calculate Out[1]-Out[3], I get - >> >>729335.000000000000000000000000000 >> >>You took an integer times a machine precision number, multiplied them, >>and set the precision of the result to 50 digits. So now the difference >>is checked to 50 digits. As they only agree to 16 or so, you see a >>residual around 10^6 in magnitude. >> >> >>Daniel Lichtblau >>Wolfram Research >> >> >> > > > ------=_Part_7128_11410184.1149701549133 > > <div>Dan, thanks very much for your response. The first one is clear now, but I still have a question with the second one. Please let me know if I am incorrect in the following interpretation.</div> > <div> </div> > <div>If as you have said, the difference is checked to 16 digits in case of a machine precision number and 50 digits in the case where precision is set to 50, then should I not see at most something like <strong>-729335 x > </strong> <strong>10^(-16),</strong> or something smaller than that. </div> > <div>Even with higher precision at least the first 16 digits should be the same as the exact number (especially, since they are the same with less precise, machine precision number).</div> > <div> </div> > <div>Thanks,</div> > <div>Bharat.</div> > <div> </div> > <div> </div> > <div> </div> > <div>>> In[2]: 123456789123 * 123456789123.0<br><br>>> Out[2]: 1.52416 =D7 10^22</div> > <div> </div> > <div>Out[2] is a machine-precision number. <br> </div> > <div><br>>> In[3]:SetPrecision[ 123456789123 * 123456789123.0 , 50 ]<br>>> Out[3]: 1.5241578780560891838464000000000000000000000000000 x 10^22</div> > <div> </div> > <div>Out[3] has greater precision than the machine precision number. </div> > <div> </div> > <div>Why should Out[3] be farther than the exact number? <br><br> </div> > <div><span class="gmail_quote">On 6/7/06, <b class="gmail_sendername">Daniel Lichtblau</b> <<a href="mailto:danl at wolfram.com">danl at wolfram.com</a>> wrote:</span> > <blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Bharat Bhole wrote:<br>> Would appreciate if someone can point out why Mathematica is not giving the<br> > > expected output in the followng two cases.<br>><br>> (1) I was trying to solve the follwing two linear equations using 'Solve'.<br>><br>><br>> *In: Solve[{64919121*x-159018721*y=8A1,41869520.5*x-102558961*y=8A0 > },{x,y}]*<br>><br>> *Out: {}*<br>><br>> However, the solution exists and is given by x = 205117922, y = 83739041<br>><br>> Why is Mathematica unable to solve this simple linear equation? Am I doing<br>> something wrong? > <br><br>You are using machine precision inputs. The coefficient matrix has a<br>linear dependency to machine precision. You might instead do:<br><br>Solve[{64919121*x-159018721*y==1,<br> (41869520+1/2)*x-102558961*y==0}, {x,y}] > <br><br><br>> (2) I suppose that the default precision for numerical calculations is<br>> MachinePrecision which is less than 16. If I increase the precision, should<br>> I not get more accurate results? The example below seems to contradict that. > <br>><br>> (i) Exact Calculation<br>><br>> *In[1]: 123456789123 * 123456789123*<br>><br>> *Out[1]: 15241578780560891109129*<br>><br>> (ii) Numerical Calculation with Default Precision<br>><br>> *In[2]: 123456789123 * > 123456789123.0*<br>><br>> *Out[2]: 1.52416 =D7 10^22*<br>><br>> (iii) Numerical Calcuation with a higher precision.<br>><br>> *In[3]:SetPrecision[ 123456789123 * 123456789123.0 , 50 ]*<br>><br>> *Out[3]: > 1.5241578780560891838464000000000000000000000000000 x 10^22*<br>><br>> Now if I calculate Out[1]-Out[2], I get zero.<br><br>The difference is only checked to machine precision. If you think about<br>it you quickly realize one cannot possibly get more information out of > <br>In[2] than that.<br><br><br>> But if I calculate Out[1]-Out[3], I get -729335.000000000000000000000000000<br><br>You took an integer times a machine precision number, multiplied them,<br>and set the precision of the result to 50 digits. So now the difference > <br>is checked to 50 digits. As they only agree to 16 or so, you see a<br>residual around 10^6 in magnitude.<br><br><br>Daniel Lichtblau<br>Wolfram Research<br><br><br></blockquote></div><br> > > ------=_Part_7128_11410184.1149701549133--

**References**:**Two questions (1) Sollve and (2) Precision***From:*"Bharat Bhole" <bbhole@gmail.com>

**Re: Two questions (1) Sollve and (2) Precision***From:*"Bharat Bhole" <bbhole@gmail.com>