Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

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>&nbsp;</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&nbsp;&nbsp;<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>&nbsp;</div>
> <div>Thanks,</div>
> <div>Bharat.</div>
> <div>&nbsp;</div>
> <div>&nbsp;</div>
> <div>&nbsp;</div>
> <div>&gt;&gt; In[2]: 123456789123 * 123456789123.0<br><br>&gt;&gt; Out[2]: 1.52416 =D7 10^22</div>
> <div>&nbsp;</div>
> <div>Out[2] is a machine-precision number. <br>&nbsp;</div>
> <div><br>&gt;&gt;&nbsp; In[3]:SetPrecision[ 123456789123 * 123456789123.0 , 50 ]<br>&gt;&gt;&nbsp; Out[3]: 1.5241578780560891838464000000000000000000000000000 x 10^22</div>
> <div>&nbsp;</div>
> <div>Out[3] has greater precision than the machine precision number. </div>
> <div>&nbsp;</div>
> <div>Why should Out[3] be farther than the exact number? <br><br>&nbsp;</div>
> <div><span class="gmail_quote">On 6/7/06, <b class="gmail_sendername">Daniel Lichtblau</b> &lt;<a href="mailto:danl at wolfram.com">danl at wolfram.com</a>&gt; 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>&gt; Would appreciate if someone can point out why Mathematica is not giving the<br>
> &gt; expected output in the followng two cases.<br>&gt;<br>&gt; (1) I was trying to solve the follwing two linear equations using 'Solve'.<br>&gt;<br>&gt;<br>&gt; *In: Solve[{64919121*x-159018721*y=8A1,41869520.5*x-102558961*y=8A0
> },{x,y}]*<br>&gt;<br>&gt; *Out: {}*<br>&gt;<br>&gt; However, the solution exists and is given by&nbsp;&nbsp;x = 205117922, y = 83739041<br>&gt;<br>&gt; Why is Mathematica unable to solve this simple linear equation? Am I doing<br>&gt; 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>&nbsp;&nbsp;(41869520+1/2)*x-102558961*y==0}, {x,y}]
> <br><br><br>&gt; (2) I suppose that the default precision for numerical calculations is<br>&gt; MachinePrecision which is less than 16. If I increase the precision, should<br>&gt; I not get more accurate results? The example below seems to contradict that.
> <br>&gt;<br>&gt; (i) Exact Calculation<br>&gt;<br>&gt; *In[1]: 123456789123 * 123456789123*<br>&gt;<br>&gt; *Out[1]: 15241578780560891109129*<br>&gt;<br>&gt; (ii) Numerical Calculation with Default Precision<br>&gt;<br>&gt; *In[2]: 123456789123 * 
> 123456789123.0*<br>&gt;<br>&gt; *Out[2]: 1.52416 =D7 10^22*<br>&gt;<br>&gt; (iii) Numerical Calcuation with a higher precision.<br>&gt;<br>&gt; *In[3]:SetPrecision[ 123456789123 * 123456789123.0 , 50 ]*<br>&gt;<br>&gt; *Out[3]: 
> 1.5241578780560891838464000000000000000000000000000 x 10^22*<br>&gt;<br>&gt; 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>&gt; But if I calculate Out[1]-Out[3], I get&nbsp;&nbsp;-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--


  • Prev by Date: rules for using functions as basis vectors
  • Next by Date: Re: Plotting Cosh(x)?
  • Previous by thread: Re: Two questions (1) Sollve and (2) Precision
  • Next by thread: RE: Two questions (1) Sollve and (2) Precision