Re: Coaxing N[] to work
- To: mathgroup at smc.vnet.net
 - Subject: [mg73410] Re: Coaxing N[] to work
 - From: "dimitris" <dimmechan at yahoo.com>
 - Date: Thu, 15 Feb 2007 05:10:23 -0500 (EST)
 - References: <equo6r$in0$1@smc.vnet.net>
 
N is often the subject of queries in this forum especially for
persons
not so experienced in Mathematica.
In your example N works in the desirable way.
Note that you have used inexact numbers like 2.0 and 1.0 of
MachinePrecision
In[82]:=
Precision[1.0]
Out[82]=
MachinePrecision
and in the end you want you want your output with almost 30 digits of
precision!
3=2E0 (also 3.) IS different from 3
In[83]:=
Head /@ {3., 3., 3}
Out[83]=
{Real, Real, Integer}
Also
In[84]:=
Precision /@ {3.2, 3.23456789023, 44/3, Sqrt[3.], 3., 3, Sqrt[3]}
Out[84]=
{MachinePrecision, MachinePrecision, Infinity, MachinePrecision,
MachinePrecision, Infinity,Infinity}
So the correct code here is
In[85]:=
x = {2, 3, 5};
A = {{6, 2, 1}, {2, 3, 1}, {1, 1, 1}};
For[k = 0, k < 15, ++k, lambda = x . A . x/x . x; y = LinearSolve[A,
x]; x = y/Norm[y, Infinity]; ]
N[lambda, 30]
Out[88]=
0=2E578933385691052787623495851171798813974781362303`30.
In[89]:=
Precision[%]
Out[89]=
30.
Execute the following command for more details (or search within the
archives of this forum)
FrontEndExecute[{HelpBrowserLookup["MainBook", "3.1"]}]
Also
http://library.wolfram.com/infocenter/Demos/91/
Best Regards
Dimitris
P=2ES. This is a friendly advice and please don't misunderstand me:
first learn Mathematica and after criticize it!
This attitude will make better and better in its using!
=CF/=C7 p at dirac.org =DD=E3=F1=E1=F8=E5:
> 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?