Re: Decimals and other numbers

2015-01-10 Thread alister
On Fri, 09 Jan 2015 19:57:20 -0800, Devin Jeanpierre wrote: On Fri, Jan 9, 2015 at 7:05 PM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: It's far from clear what *anything* multiplied by itself zero times should be. A better way of thinking about what x**n for integer n means is this:

Re: Decimals and other numbers

2015-01-09 Thread Gregory Ewing
Steven D'Aprano wrote: I'm just sketching an informal proof. If you want to make it vigorous I think the usual term is rigorous, unless the mathematician is taking some kind of stimulant... :-) -- Greg --

Re: Decimals and other numbers

2015-01-09 Thread Gregory Ewing
Steven D'Aprano wrote: Arguably, *integer* 0**0 could be zero, on the basis that you can't take limits of integer-valued quantities, and zero times itself zero times surely has to be zero. It's far from clear what *anything* multiplied by itself zero times should be. A better way of thinking

Re: Decimals and other numbers

2015-01-09 Thread Devin Jeanpierre
On Fri, Jan 9, 2015 at 2:20 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: -snip- I don't understand what you're trying to say here. You can't just arbitrarily declare that 0**1 equals something other than 0 (or for that matter, doesn't equal anything at all). You can,

Re: Decimals and other numbers

2015-01-09 Thread Devin Jeanpierre
On Fri, Jan 9, 2015 at 7:05 PM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: It's far from clear what *anything* multiplied by itself zero times should be. A better way of thinking about what x**n for integer n means is this: Start with 1, and multiply it by x n times. The result of this

Re: Decimals and other numbers

2015-01-09 Thread Steven D'Aprano
Devin Jeanpierre wrote: On Thu, Jan 8, 2015 at 6:43 PM, Dave Angel da...@davea.name wrote: What you don't say is which behavior you actually expected. Since 0**0 is undefined mathematically, I'd expect either an exception or a NAN result. It can be undefined, if you choose for it to be.

Re: Decimals and other numbers

2015-01-09 Thread Devin Jeanpierre
Marko, your argument is this function x**y(a, x) must be continuous on [0, inf), and to be continuous at 0, 0**0 must be a. Since there are many possible values of a, this is not a justification, this is a proof by contradiction that the premise was faulty: x**y(a, x) doesn't have to be continuous

Re: Decimals and other numbers

2015-01-09 Thread Jussi Piitulainen
Devin Jeanpierre writes: [...] domain of the natural numbers. Knuth says that thought of combinatorially on the naturals, x**y counts the number of mappings from a set of x values to a set of y values. It's the other way around, of course: from a set of y values to a set of x values. Which

Re: Decimals and other numbers

2015-01-09 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: I'm not a mathematical expert, so I don't quite 'get' this. How does this justify 0**0 being equal to 0.5? Many operations like this are defined in terms of some very strong argument of uniqueness. Ultimately, the key point is safety in mathematical deductions.

Re: Decimals and other numbers

2015-01-09 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Devin Jeanpierre wrote: No you can't -- that would make arithmetic inconsistent. 0**1 is perfectly well defined as 0 however you look at it: You *could* leave 0**1 undefined. You *could* leave 7+0 undefined. However, that would make

Re: Decimals and other numbers

2015-01-09 Thread Steven D'Aprano
I think we're in violent agreement here, nevertheless I think you're right for the wrong reasons. See below... Devin Jeanpierre wrote: On Fri, Jan 9, 2015 at 12:49 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Devin Jeanpierre wrote: On Thu, Jan 8, 2015 at 6:43 PM, Dave

Re: Decimals and other numbers

2015-01-09 Thread Devin Jeanpierre
On Fri, Jan 9, 2015 at 12:58 AM, Devin Jeanpierre jeanpierr...@gmail.com wrote: Arguably, *integer* 0**0 could be zero, on the basis that you can't take limits of integer-valued quantities, and zero times itself zero times surely has to be zero. I should have responded in more detail here,

Re: Decimals and other numbers

2015-01-09 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: mathematicians with a pragmatic bent You shouldn't call engineers and scientists mathematicians (with a pragmatic bent). Rigor is an absolute requirement for any mathematics. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Decimals and other numbers

2015-01-09 Thread Devin Jeanpierre
On Fri, Jan 9, 2015 at 12:49 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Devin Jeanpierre wrote: On Thu, Jan 8, 2015 at 6:43 PM, Dave Angel da...@davea.name wrote: What you don't say is which behavior you actually expected. Since 0**0 is undefined mathematically, I'd

Re: Decimals and other numbers

2015-01-09 Thread Chris Angelico
On Fri, Jan 9, 2015 at 9:20 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On the basis that m**n means m multiplied by itself n times: 5**4 = 5*5*5*5 = 625 that gives us: 0**0 = zero multiplied by itself zero times. You can multiply 0 by any number you like, and the

Re: Decimals and other numbers

2015-01-09 Thread Steven D'Aprano
Marko Rauhamaa wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: mathematicians with a pragmatic bent You shouldn't call engineers and scientists mathematicians (with a pragmatic bent). Rigor is an absolute requirement for any mathematics. I wasn't referring to engineers,

Re: Decimals and other numbers

2015-01-09 Thread Steven D'Aprano
I want to emphasis that I'm not really arguing that 0**0 should evaluate as 0. That's probably the least useful thing we can have out of the four possibilities: - return 1 - return NAN - raise an exception - return 0 But in the spirit of the Devil's Advocate, I mentioned that there was an

Re: Decimals and other numbers

2015-01-09 Thread Chris Angelico
On Fri, Jan 9, 2015 at 11:24 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: 5 * 0 * 0 * 0 * 0 = 0 Where did the 5 come from? You're effectively saying that 0**0 becomes 5*0**0, then cancelling the 0**0 because they're all zeroes and so don't matter, leaving 5. And that

Re: Decimals and other numbers

2015-01-08 Thread Chris Rebert
On Thu, Jan 8, 2015 at 6:33 PM, Devin Jeanpierre jeanpierr...@gmail.com wrote: I noticed some very PHP-ish behavior today: import decimal x = 0 y = float(x) z = decimal.Decimal(x) x == y == z == x True x ** x 1 y**y 1.0 z**z Traceback (most recent call last): File stdin, line 1,

Re: Decimals and other numbers

2015-01-08 Thread Devin Jeanpierre
On Thu, Jan 8, 2015 at 6:43 PM, Dave Angel da...@davea.name wrote: What you don't say is which behavior you actually expected. Since 0**0 is undefined mathematically, I'd expect either an exception or a NAN result. It can be undefined, if you choose for it to be. You can also choose to not

Re: Decimals and other numbers

2015-01-08 Thread Devin Jeanpierre
Thanks Ben, with your encouragement I have filed http://bugs.python.org/issue23201 -- Devin On Thu, Jan 8, 2015 at 7:03 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: Dave Angel da...@davea.name writes: What you don't say is which behavior you actually expected. Since 0**0 is undefined

Decimals and other numbers

2015-01-08 Thread Devin Jeanpierre
I noticed some very PHP-ish behavior today: import decimal x = 0 y = float(x) z = decimal.Decimal(x) x == y == z == x True x ** x 1 y**y 1.0 z**z Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.7/decimal.py, line 2216, in __pow__ return

Re: Decimals and other numbers

2015-01-08 Thread Ben Finney
Dave Angel da...@davea.name writes: What you don't say is which behavior you actually expected. Since 0**0 is undefined mathematically, I'd expect either an exception or a NAN result. Do you think that the ‘int’ and ‘float’ types, which do produce a number result for ‘0 ** 0’, are buggy and

Re: Decimals and other numbers

2015-01-08 Thread Dave Angel
On 01/08/2015 09:33 PM, Devin Jeanpierre wrote: I noticed some very PHP-ish behavior today: import decimal x = 0 y = float(x) z = decimal.Decimal(x) x == y == z == x True x ** x 1 y**y 1.0 z**z Traceback (most recent call last): File stdin, line 1, in module File

Re: Decimals and other numbers

2015-01-08 Thread Marko Rauhamaa
Dave Angel da...@davea.name: What you don't say is which behavior you actually expected. Since 0**0 is undefined mathematically, I'd expect either an exception or a NAN result. IEEE 754 mandates that 0**0 should evaluate to 1: URL:

Re: Decimals and other numbers

2015-01-08 Thread Dave Angel
On 01/09/2015 02:37 AM, Chris Angelico wrote: On Fri, Jan 9, 2015 at 6:28 PM, Marko Rauhamaa ma...@pacujo.net wrote: Devin Jeanpierre jeanpierr...@gmail.com: If 0**0 is defined, it must be 1. You can justify any value a within [0, 1]. For example, choose y(a, x) = log(a, x) Then,

Re: Decimals and other numbers

2015-01-08 Thread Marko Rauhamaa
Devin Jeanpierre jeanpierr...@gmail.com: If 0**0 is defined, it must be 1. You can justify any value a within [0, 1]. For example, choose y(a, x) = log(a, x) Then, limy(a, x) = 0 x - 0+ and: lim[x - 0+] x**y(a, x) = a For example, a = 0.5 x = 1e-100 y =

Re: Decimals and other numbers

2015-01-08 Thread Chris Angelico
On Fri, Jan 9, 2015 at 6:28 PM, Marko Rauhamaa ma...@pacujo.net wrote: Devin Jeanpierre jeanpierr...@gmail.com: If 0**0 is defined, it must be 1. You can justify any value a within [0, 1]. For example, choose y(a, x) = log(a, x) Then, limy(a, x) = 0 x - 0+ and:

Re: Decimals and other numbers

2015-01-08 Thread Ben Finney
Devin Jeanpierre jeanpierr...@gmail.com writes: decimal.InvalidOperation: 0 ** 0 I'd file a bug report but I'm anticipating some rational (heh) explanation. Any ideas? First note that it's explicitly documented as an invalid operation