[Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison

Huaiyu Zhu hzhu at users.sourceforge.net
Wed Oct 25 22:05:29 EDT 2000


On Wed, 25 Oct 2000 09:35:03 -0400, Charles Boncelet <boncelet at udel.edu> wrote:

>right question to ask is "what do serious programmers want?"

If "serious" means "math-oriented", or "concerned with correctness", the
answer is probably

2-7==-5;   9/6==3/2;  sqrt(-4)==2j

The following are equally unacceptable:

2-7==0; 5/3==1; sqrt(-2)==0.

These operations are not closed in the set their operands are defined.
Historically, numbers are extended precisely for the reason that they
represent previously "meaningless" results.

If "serious" just means "having to deal with this stuff very often", it
depends on what they actually do.  It is possible in some circumstances that
having the results being of the same type of the operands is convenient.
Such shortcuts are not natural and they are not obvious to new-commers.

However, the extended types of numbers are often needed even when one's
final answer is going to be of the same type as the inputs.  Imagine that
negative or non-integer numbers are banned from a population prediction
model because the number of humans has to be a non-negative integer! Another
example, the formula for solving a cubic equation often use imaginary
intermediate results even if the equation coefficients and the final
solution are all real numbers.

So let's ask the question in another way: Is there a technical reason
(performance, implementation details, etc) not to have a rational type,
given the existence of a complex type?

Huaiyu



More information about the Python-list mailing list