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

*To*: mathgroup at smc.vnet.net*Subject*: [mg67065] Re: Two questions (1) Sollve and (2) Precision*From*: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>*Date*: Thu, 8 Jun 2006 04:54:05 -0400 (EDT)*References*: <e666j8$nbj$1@smc.vnet.net> <4486B0CA.3060002@gmail.com> <a3224ef10606070653u22303b57g87c303547b8913ab@mail.gmail.com>*Sender*: owner-wri-mathgroup at wolfram.com

On 6/7/06, Bharat Bhole <bbhole at gmail.com> wrote: > > Thanks for your help Jean-Marc. I really appreciate it. I have two comments > about your response, and it would be very helpful if things work on your > computer after taking these into account. > > (1) As I replied to all, somehow my equations were posted with an error. > The right hand sides in the two equations were 1 and 0 respectively and not > 8A1 and 8A0. Also, I had used two equal signs (== and not just = when > writing the equations). OK! I spotted the single equal sign but not the additional 8A. Now, I've got the same result as yours, that is an empty list. Also, I have tried Reduce and FindInstance with no more success. In[1]:= Solve[{64919121*x - 159018721*y == 1, 4.18695205*^7*x - 102558961*y == 0}, {x, y}] Out[1]= {} In[2]:= $Version Out[2]= 5.2 for Microsoft Windows (June 20, 2005) In[3]:= Reduce[{64919121*x - 159018721*y == 1, 4.18695205*^7*x - 102558961*y == 0}, {x, y}] Out[3]= False In[4]:= Reduce[{64919121*x - 159018721*y == 1., 4.18695205*^7*x - 102558961*y == 0.}, {x, y}] Out[4]= False In[5]:= FindInstance[{64919121 x-159018721 y\[Equal]1.,4.18695205*^7 x-102558961 y\[Equal]0.},{x,y}] Out[5]= {} In[6]:= {64919121*x - 159018721*y == 1, 4.18695205*^7*x - 102558961*y == 0} /. {x -> 205117922, y -> 83739041} Out[6]= {True,True} > (2) For the second problem you have calculated %%%-%. So basically you are > calculating Out[5]-Out[7] in your solution below. However, I was talking > about Out[4]-Out[7], which is not zero even in your case. Sorry about that, I miscounted the number of outputs! Again, I got the same rsult as yours: In[8]:= 123456789123*123456789123-SetPrecision[123456789123*123456789123.0,50] Out[8]= -729335.000000000000000000000000000 Best regards, Jean-Marc > Thanks very much. > > > Bharat. > > > On 6/7/06, Jean-Marc Gulliet <jeanmarc.gulliet at gmail.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. > > > > Here is what I get with Mathematica > > > > In[3]:= > > $Version > > > > Out[3]= > > 5.2 for Microsoft Windows (June 20, 2005) > > > > > (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: {}* > > > > > In[1]:= > > Solve[{64919121*x - 159018721*y == 8*A1, > > 4.18695205*^7*x - 102558961*y == 8*A0}, {x, y}] > > > > Out[1]= > > 9 8 > > {{x -> -1.27215 10 A0 + 8.20472 10 A1, > > > > 8 8 > > y -> -5.19353 10 A0 + 3.34956 10 A1}} > > > > > > > However, the solution exists and is given by x = 205117922, y = > 83739041 > > > > It is meaningless to speak about "The" solution if you do not tell what > > values A0 and A1 have been assigned: > > > > In[2]:= > > Solve[{64919121*x - 159018721*y == 8*A1, > > 4.18695205*^7*x - 102558961*y == 8*A0} /. > > {x -> 205117922, y -> 83739041}, {A0, A1}] > > > > Out[2]= > > {{A1 -> 0.125, A0 -> 0.}} > > > > > Why is Mathematica unable to solve this simple linear equation? Am I > doing > > > something wrong? > > > > > > > > > > > > (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. > > > > > > But if I calculate Out[1]-Out[3], I get > -729335.000000000000000000000000000 > > > . > > > > > > This seems to suggest that calculation 2 is more accurate even though it > has > > > smaller precision. Where am I making a mistake? > > > > > > Thanks very much for your help. > > > > > > > > > > What version of Mathematica do you use? Work fine for me: > > > > In[4]:= > > 123456789123*123456789123 > > > > Out[4]= > > 15241578780560891109129 > > > > In[5]:= > > 123456789123*123456789123.0 > > > > Out[5]= > > 22 > > 1.52416 10 > > > > In[6]:= > > %%-% > > > > Out[6]= > > 0. > > > > In[7]:= > > SetPrecision[123456789123*123456789123.0,50] > > > > Out[7]= > > 1.5241578780560891838464000000000000000000000000000 > > > > 22 > > 10 > > > > In[8]:= > > %%%-% > > > > Out[8]= > > 0. > > > > In[9]:= > > $Version > > > > Out[9]= > > 5.2 for Microsoft Windows (June 20, 2005) > > > > Regards, > > Jean-Marc > > > >