Re: numerics

*To*: mathgroup at smc.vnet.net*Subject*: [mg27283] Re: [mg27276] numerics*From*: Tomas Garza <tgarza01 at prodigy.net.mx>*Date*: Sat, 17 Feb 2001 03:30:59 -0500 (EST)*References*: <200102160858.DAA13479@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

It seems the problem arises from precision. See, if you look at FullForm: In[1]:= FullForm[newmat] Out[1]//FullForm= List[List[-0.19999999999999996`, 0.1`, 0], List[0.1`, -0.30000000000000004`, 0.1`], List[0.1`, 0.2`, -0.09999999999999998`]] and this messes up the whole situation. Of course, it all depends on the actual numbers you're dealing with in your problem, but if you rationalize the input in your example, you obtain In[2]:= mat2 = Rationalize[mat1] Out[2]= {{4/5, 1/10, 1/10}, {1/10, 7/10, 1/5}, {0, 1/10, 9/10}} Now you take In[3]:= newmat2 = Transpose[mat2] - imat so that In[4]:= newmat2 == mat Out[4]= True and now In[5]:= Reduce[newmat2.{x1, x2, x3} == {0, 0, 0}, {x1, x2, x3}] Out[5]= x1 == x2/2 && x3 == (5*x2)/2 which is what you were expecting. No loss of precision with rationals. Tomas Garza Mexico City ----- Original Message ----- From: <Matt.Johnson at autolivasp.com> To: mathgroup at smc.vnet.net Subject: [mg27283] [mg27276] numerics > mathematica gurus-- > > Here's a frustrating problem, which seems to be simple. I can calculate a > matrix by hand and enter it into Solve or Reduce and get the correct > relationships: > > In[108]:= > mat = Partition[{-0.2, 0.1, 0, 0.1, -0.3, 0.1, 0.1, 0.2, -0.1}, 3]; > Reduce[mat.{x1, x2, x3} == {0, 0, 0}, {x1, x2, x3}] > Out[109]= > x1 == 0.5 x2 && x3 == 2.5 x2 > > However, if I try to manipulate the matrix in Mathematica then solve, it doesn't work: > > In[110]:= > mat1 = Partition[{0.8, 0.1, 0.1, 0.1, 0.7, 0.2, 0, 0.1, 0.9}, 3]; > imat = IdentityMatrix[Length[mat1]]; > newmat = Transpose[mat1] - imat; > In[113]:= > newmat == mat > Out[113]= > True > In[114]:= > newmat === mat > Out[114]= > False > In[115]:= > Reduce[newmat.{x1, x2, x3} == {0, 0, 0}, {x1, x2, x3}] > Out[115]= > x1 == 0. && x2 == 0. && x3 == 0. > > any input? > > -matt > **************************************************************************** ********************************************************** > All Autoliv e-mails remain Company property and shall be used for > business-related purposes only. Do not forward any material contained > within this e-mail without prior, written permission from the author's > manager. Autoliv disclaims all responsibility and accepts no liability > (including negligence) for the consequences for any person acting, or > refraining from acting on this information prior to the receipt by those > persons of subsequent written confirmation. > **************************************************************************** ********************************************************** > > >

**Follow-Ups**:**Out of Memory. Exiting.***From:*"Ivan Stegic" <ivan@stegic.com>

**References**:**numerics***From:*Matt.Johnson@autolivasp.com