On Mon, Mar 31, 2014 at 02:17:56PM -0700, Richard Fateman wrote:
>    I think the answer from a practical perspective is that you can't exclude
>    floats.

But why we need them as a class, derived from Number and Basic?

An example of real issue:
In [1]: n1=Float(0.001)
In [2]: n2=Float(1.1)
In [3]: n3=Float(1.0)
In [4]: x1=n1*x
In [5]: x2=n2*x
In [6]: x3=n3*x
In [10]: f1=Add(Add(x1, x2, evaluate=False), -x3, evaluate=False)
In [11]: f1
Out[11]: -1.0*x + 0.001*x + 1.1*x
In [13]: f2=Add(x1, Add(x2, -x3, evaluate=False), evaluate=False)
In [14]: f1
Out[14]: -1.0*x + 0.001*x + 1.1*x
In [20]: f1-f2 # Hey, sympy thinks associativity holds
Out[20]: 0

But:
In [21]: f1e=Add(Add(x1, x2), -x3); f1e
Out[21]: 0.101*x
In [22]: f2e=Add(x1, Add(x2, -x3)); f2e
Out[22]: 0.101*x
In [23]: f1e-f2e
Out[23]: -1.11022302462516e-16*x

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

Yes, for the provided example (x**0.5)

>      End of story.  It seems, people want to introduce not floats but a fancy
>      notation for rationals.
>
>    You can't predict the future.

I'm not attempting to do so.

>       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.

But I don't suggest to forbid using float at all (python has builtin
float type, we also have mpf from mpmath; we can convert SymPy's numbers to 
these
types in some use cases).

>      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.

Good point.  But if we don't need them now - it's a good idea to
introduce such an object only on demand...

-- 
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/20140404144411.GA23457%40darkstar.order.hcn-strela.ru.
For more options, visit https://groups.google.com/d/optout.

Reply via email to