On Monday, March 31, 2014 9:28:23 AM UTC-7, Sergey Kirpichev wrote:
>
> On Sat, Mar 29, 2014 at 01:28:54PM -0700, Richard Fateman wrote: 
> >    Common Lisp uses floating-point arithmetic for floats, exact 
> arithmetic 
> >    for the data type used for rationals. 
>
> Good news.  Python does same. 
>
> >    If you stick with integers and ratios of integers, Common 
> >    Lisp does mathematically valid  arithmetic. 
>
> Excelent!  Python too. 
>
> The problem is: float arithmetic is not a "valid arithmetic" by 
> design.  And the question is: should we use float "numbers" in SymPy 
> at all. 
>

I think the answer from a practical perspective is that you can't exclude 
floats.
 

>
> >      But I admit, we shouldn't allow 
> >      using of Float's (or builtin float type) in symbolic mathematics. 
> > 
> >    I disagree, from experience.  People want to introduce floats.  For 
> >    example, some people 
> >    write squareroot(x)   as  x^0.5 
> >    Saves typing, and they believe it is the same thing. 
>
> But that's not necessary floats!  It's just a different 
> notation for rational 1/2 (as "they believe"). 
>

So are you taking the view, now, that 0.5 is rational?
 

>
> In [1]: Rational('0.123') 
> Out[1]: 
> 123 
> ──── 
> 1000 
> In [2]: Float('0.123') 
> Out[2]: 0.123000000000000 
> In [3]: type(_) 
> Out[3]: sympy.core.numbers.Float 
> In [4]: sympify('0.123') 
> Out[4]: 0.123000000000000 
> In [5]: type(_) 
> Out[5]: sympy.core.numbers.Float 
>
> The little problem here is that float(0.3) != 3/10 internally, for 
> example (despite people think so).  See this: 
> https://docs.python.org/2/tutorial/floatingpoint.html 
>
> In [16]: Decimal(0.3) 
> Out[16]: 
> Decimal('0.299999999999999988897769753748434595763683319091796875') 
> In [17]: Rational(0.3) 
> Out[17]: 
>  5404319552844595 
>  ───────────────── 
>  18014398509481984 
> In [18]: Rational(str(0.3)) 
> Out[18]: 3/10 
>
> End of story.  It seems, people want to introduce not floats but a fancy 
> notation for rationals.


You can't predict the future.
 

>  If this is only the reason why we keep Float 
> object - we should drop Float's and fix sympify to map python's floats 
> to Rational's instead (for example: sympify(0.2) -> Rational(str(0.2))). 
>
Sometimes floats can be very handy.  Finding approximations to roots
of a polynomial.  Compared to rational arithmetic, where different, usually
much slower methods, might be used. 

>
> Is there a real need for floats in symbolic mathematics package? 
>
Just because you might not need them now, doesn't really answer the 
question.

 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/c4740159-94a2-4ab3-9a75-c311c172f2e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to