[Date Index]
[Thread Index]
[Author Index]
Re: Is there a simple way to transform 1.1 to 11/10?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg92980] Re: Is there a simple way to transform 1.1 to 11/10?
*From*: Alain Cochard <alain at geophysik.uni-muenchen.de>
*Date*: Wed, 22 Oct 2008 05:36:28 -0400 (EDT)
*References*: <gdkajv$4r2$1@smc.vnet.net>
*Reply-to*: alain at geophysik.uni-muenchen.de
Szabolcs Horv=E1t writes:
> On Tue, Oct 21, 2008 at 14:49, Alain Cochard
> <alain at geophysik.uni-muenchen.de> wrote:
> > Szabolcs Horvat writes:
> > > Alain Cochard wrote:
> > > > The obvious
> > > >
> > > > In[1]:= x=1.1`Infinity
> > > >
> > > > is not syntactically correct.
> > > >
> > > > I understand that SetPrecision[1.1,Infinity] does not work ei=
ther:
> > > >
> > > > In[3]:= SetPrecision[1.1,Infinity]
> > > >
> > > > 2476979795053773
> > > > Out[3]= ----------------
> > > > 2251799813685248
> > > >
> > > > In[4]:= N[%,20]
> > > >
> > > > Out[4]= 1.1000000000000000888
> > > >
> > > > I searched the newsgroup and thought I had the solution with =
Rationalize:
> > > >
> > > > In[5]:= Rationalize[1.1,0]
> > > >
> > > > 11
> > > > Out[5]= --
> > > > 10
> > > >
> > > > But
> > > >
> > > > In[9]:= Rationalize[1.000000001,0]
> > > >
> > > > 999999918
> > > > Out[9]= ---------
> > > > 999999917
> > > >
> > > > In[10]:= N[%,20]
> > > >
> > > > Out[10]= 1.0000000010000000830
> > > >
> > > > So any simple way=3F
> > > >
> > >
> > > Hello Alain,
> > >
> > > Rationalize is the way to go. Floating point numbers are usual=
ly stored
> > > in a binary (not decimal) representation on computers. 1.00000=
0001 is
> > > not exactly representable in binary (in the same way as 1/3 ==
> > > 0.3333333... is not exactly representable in decimal). Note th=
at in
> > > your example you start with a MachinePrecision number (approxim=
ately 15
> > > digits), and then convert back to a number with 20 digits of pr=
ecision.
> > > If you start with 1.000000001`20 then everything will be fine=
=2E
> > >
> > > In[1]:= Rationalize[1.000000001`20, 0]
> > > Out[1]= 1000000001/1000000000
> > >
> > > In[2]:= N[%, 20]
> > > Out[2]= 1.0000000010000000000
> > >
> > > Another example:
> > >
> > > In[1]:= Rationalize[N[Sqrt[2], 30], 0]
> > > Out[1]= 1023286908188737/723573111879672
> > >
> > > In[2]:= N[%, 30]
> > > Out[2]= 1.41421356237309504880168872421
> > >
> > > In[3]:= % - Sqrt[2]
> > > Out[3]= 0.*10^-30
> >
> > I don't really convert back to a number with 20 digits of precisio=
n.
>
> You used N[%,20] in your example where % was the rationalization of =
a
> MachinePrecision number. If you convert it back to a MachinePrecisi=
on
> number (simply N[%]), then you'll get the same number that you start=
ed
> with, and not a different one.
>
> > It was just to convince myself that it was not 1000000001/10000000=
00
>
> Actually 1.000000001 isn't 1000000001/1000000000 either ... see belo=
w.
>
> > The solution you give will not be fully general (as that by bob) s=
ince
> > you have to adapt the '20' or the '30' for each case. This is a b=
it
> > painful for a given number and impossible to do in a program, it s=
eems
> > to me.
> >
>
> No, you misunderstood me. I did not offer a solution. I just tried=
> to explain why the result returned by Rationalize[1.000000001,0] is
> correct, and why the "problem" does not exist at all.
Sorry that I misundertood you. Also, I wasn't implying the Mathematica does
not give the correct result.
There is a problem for me because when I play with mathematical
numbers like 1.608910743981704391 with an infinite number of zeroes
afterwards, it is painful to manually count the figures and write it
as 1608910743981704391/1000000000000000000
> You asked how you can transform 1.1 to 11/10. This is not a
> precisely defined question. Why do you prefer 11/10=3F Why not
> 1100000000000000088/1000000000000000000, for example=3F
Because I'd say that for pure mathematics, 11/10 is closer to 1.1 than
1100000000000000088/1000000000000000000 is...
>
> [...]
>
> What I meant was that you have to decide what precision to use. [...]
I want infinite precision, juste like when you enter 1, Pi, or 11/10.
Prev by Date:
**Re: my Mathematica file was corrupted ! help !**
Next by Date:
**Re: A Dynamic mess**
Previous by thread:
**Re: Is there a simple way to transform 1.1 to 11/10?**
Next by thread:
**Re: Is it possible to reverse "Color Schames" function ?**
| |