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

• To: mathgroup at smc.vnet.net
• Subject: [mg67051] Re: [mg67035] Two questions (1) Sollve and (2) Precision
• From: "Bharat Bhole" <bbhole at gmail.com>
• Date: Thu, 8 Jun 2006 04:53:24 -0400 (EDT)
• References: <200606070910.FAA23549@smc.vnet.net> <4486F6B4.5070905@wolfram.com>
• Sender: owner-wri-mathgroup at wolfram.com

```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.

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.
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: 123456789123 * 123456789123.0

>> Out: 1.52416 =D7 10^22

Out is a machine-precision number.

>>  In:SetPrecision[ 123456789123 * 123456789123.0 , 50 ]
>>  Out: 1.5241578780560891838464000000000000000000000000000 x 10^22

Out has greater precision than the machine precision number.

Why should Out 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: 123456789123 * 123456789123*
> >
> > *Out: 15241578780560891109129*
> >
> > (ii) Numerical Calculation with Default Precision
> >
> > *In: 123456789123 * 123456789123.0*
> >
> > *Out: 1.52416 =D7 10^22*
> >
> > (iii) Numerical Calcuation with a higher precision.
> >
> > *In:SetPrecision[ 123456789123 * 123456789123.0 , 50 ]*
> >
> > *Out: 1.5241578780560891838464000000000000000000000000000 x 10^22*
> >
> > Now if I calculate Out-Out, 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 than that.
>
>
> > But if I calculate Out-Out, 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: 123456789123 * 123456789123.0<br><br>&gt;&gt; Out: 1.52416 =D7 10^22</div>
<div>&nbsp;</div>
<div>Out is a machine-precision number. <br>&nbsp;</div>
<div><br>&gt;&gt;&nbsp; In:SetPrecision[ 123456789123 * 123456789123.0 , 50 ]<br>&gt;&gt;&nbsp; Out: 1.5241578780560891838464000000000000000000000000000 x 10^22</div>
<div>&nbsp;</div>
<div>Out has greater precision than the machine precision number. </div>
<div>&nbsp;</div>
<div>Why should Out 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: 123456789123 * 123456789123*<br>&gt;<br>&gt; *Out: 15241578780560891109129*<br>&gt;<br>&gt; (ii) Numerical Calculation with Default Precision<br>&gt;<br>&gt; *In: 123456789123 *
123456789123.0*<br>&gt;<br>&gt; *Out: 1.52416 =D7 10^22*<br>&gt;<br>&gt; (iii) Numerical Calcuation with a higher precision.<br>&gt;<br>&gt; *In:SetPrecision[ 123456789123 * 123456789123.0 , 50 ]*<br>&gt;<br>&gt; *Out:
1.5241578780560891838464000000000000000000000000000 x 10^22*<br>&gt;<br>&gt; Now if I calculate Out-Out, 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 than that.<br><br><br>&gt; But if I calculate Out-Out, 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: Re: Re: piecewise integration
• Next by Date: Re: Plotting Cosh(x)?
• Previous by thread: Re: Two questions (1) Sollve and (2) Precision
• Next by thread: Re: Re: Two questions (1) Sollve and (2) Precision