[Date Index]
[Thread Index]
[Author Index]
RE: Accuracy and Precision
*To*: mathgroup at smc.vnet.net
*Subject*: [mg36899] RE: Accuracy and Precision
*From*: "DrBob" <drbob at bigfoot.com>
*Date*: Tue, 1 Oct 2002 04:45:37 -0400 (EDT)
*Reply-to*: <drbob at bigfoot.com>
*Sender*: owner-wri-mathgroup at wolfram.com
Actually, we don't know whether SetAccuracy "succeeds", because we don't
know how inexact those numbers really are. If they are known to more
digits than shown in the original post, they should be entered with as
much precision as they deserve. If not, there's no trick or algorithm
that will give the result precision, because the value of f really is
"in the noise". That is, we have no idea what the value of f should be.
Mathematica's failing is in returning a value without pointing out that
it has no precision.
Bobby
-----Original Message-----
From: Allan Hayes [mailto:hay at haystack.demon.co.uk]
To: mathgroup at smc.vnet.net
Subject: [mg36899] Re: Accuracy and Precision
Andrzej, Bobby, Peter
It looks as if using SetAccuracy succeeds here because the inexact
numbers
that occur have finite binary representations. If we change them
slightly to
avoid this then we have to use Rationalize:
1) Using SetAccuracy
Clear[a,b,f]
f=SetAccuracy[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b^8+a/(2*b),
Infinity];
a=77617.1;
b=33096.1;
a=SetAccuracy[a,Infinity];b=SetAccuracy[b,Infinity];
f
-1564032114908486835197494923989618867972540153873951942813115514949
3891236234\
525007719168693704591197760187988046304361497869199129319625743010292363
1246
75\
/10867106143970760551000357827554793888198143135975649579607989867743572
8240
16\
0653953612982932181371232436367739737604096
2) Rewriting as fractions
a=776171/10;
b=330961/10;
f=33374/100*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+54/10*b^8+a/(2*b)
-(5954133808997234115690303589909929091649391296257/
41370125000000)
3) Using Rationalize
Clear[a,b,f]
f=Rationalize[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b^8+a/(2*b),
0];
a=77617.1;
b=33096.1;
a=Rationalize[a,0];b=Rationalize[b,0];
f
-(5954133808997234115690303589909929091649391296257/
41370125000000)
I use Rationalize[. , 0] besause of results like
Rationalize[3.1415959]
3.1416
Rationalize[3.1415959,0]
31415959/10000000
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
"Andrzej Kozlowski" <andrzej at tuins.ac.jp> wrote in message
news:an8s8i$6pk$1 at smc.vnet.net...
> Well, first of of all, your using SetAccuracy and SetPrecision does
> nothing at all here, since they do not change the value of a or b. You
> should use a = SetAccuracy[a, Infinity] etc. But even then you won't
> get the same answer as when you use exact numbers because of the way
> you evaluate f. Here is the order of evaluation that will give you the
> same answer, and should explain what is going on:
>
> f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*
> b^4 - 2) + 5.5*b^8 + a/(2*b), Infinity];
>
> a = 77617.;
>
>
> b = 33096.;
>
> a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity];
>
> f
>
> 54767
> -(-----)
> 66192
>
> Andrzej Kozlowski
> Toyama International University
> JAPAN
>
>
>
> On Sunday, September 29, 2002, at 03:55 PM, Peter Kosta wrote:
>
> > Could someone explain what is going on here, please?
> >
> > In[1]:=
> > a = 77617.; b = 33096.;
> >
> > In[2]:=
> > SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];
> > SetPrecision[a, Infinity]; SetPrecision[b, Infinity];
> >
> > In[4]:=
> > f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 +
> > a/(2*b)
> >
> > In[5]:=
> > SetAccuracy[f, Infinity]; SetPrecision[f, Infinity];
> >
> > In[6]:=
> > f
> >
> > Out[6]=
> > -1.1805916207174113*^21
> >
> > In[7]:=
> > a = 77617; b = 33096;
> >
> > In[8]:=
> > g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +
> > (55/10)*b^8 + a/(2*b)
> >
> > In[9]:=
> > g
> >
> > Out[9]=
> > -(54767/66192)
> >
> > In[10]:=
> > N[%]
> >
> > Out[10]=
> > -0.8273960599468214
> >
> > Thanks,
> >
> > PK
> >
> >
> >
>
>
Prev by Date:
** Re: Accuracy and Precision**
Next by Date:
**Re: Accuracy and Precision**
Previous by thread:
** Re: Accuracy and Precision**
Next by thread:
**Re: Accuracy and Precision**
| |