Re: Coaxing N[] to work
- To: mathgroup at smc.vnet.net
- Subject: [mg73483] Re: Coaxing N[] to work
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Mon, 19 Feb 2007 01:30:54 -0500 (EST)
- References: <equo6r$in0$1@smc.vnet.net>
p at dirac.org wrote: > Sometimes N[,] doesn't appear to work. Like here: > > > x = {2.0, 3.0, 5.0}; > A = { {6.0, 2.0, 1.0}, {2.0, 3.0, 1.0}, {1.0, 1.0, 1.0} }; > For[ k=0, k<15, ++k, > lambda = x.A.x/(x.x); > y = LinearSolve[A,x]; > x = y / Norm[y,Infinity]; > ] > N[lambda, 30] > > > The output is: > > Out[5]= 0.578933 > > I was expecting 30 digits. Why did N[] ignore my request for 30 digits? > While others have pointed out that lambda only has about 16 digits of precision - so you can't ask for 30 - I suspect you may be wondering where the other 10 digits have vanished! Indeed, I suspect this is the problem you were really trying to solve. Applying N in your case did nothing - the result was still a machine precision number. Such numbers are normally printed out by Mathematica with much fewer digits (just for neatness), although they are stored to full machine precision. There are several ways to view this precision, one would be: lambda //InputForm David Bailey http://www.dbaileyconsultancy.co.uk