Re: GCD in Fractions

2014-09-25 Thread Chris Angelico
On Thu, Sep 25, 2014 at 8:56 PM, Akira Li <4kir4...@gmail.com> wrote: > It might mean that you are *too observant* because I've noticed that > the order of the letters is different just now. > > http://english.stackexchange.com/questions/8628/is-it-true-that-only-the-positions-of-the-first-and-last

Re: GCD in Fractions

2014-09-25 Thread Akira Li
Mark Lawrence writes: > On 24/09/2014 12:14, Mark Dickinson wrote: >> Mark Lawrence yahoo.co.uk> writes: >>> Somebody got there first http://bugs.python.org/issue22477 >> >> I think there's good reason to suspect that Brian Gladman and >> blindanagram are one and the same. :-) >> > sorted("B

Re: GCD in Fractions

2014-09-24 Thread Robert E. Beaudoin
On 09/24/14 09:25, blindanagram wrote: On 24/09/2014 12:44, Steven D'Aprano wrote: blindanagram wrote: [snip] - Mathworld says that GCD of two negative numbers is a negative number; - but Mathematica says that GCD of two negative numbers is a positive; - Wikipedia agrees with Mathematica an

Re: GCD in Fractions

2014-09-24 Thread Johann Hibschman
Steven D'Aprano writes: > blindanagram wrote: > >> Seccondly (as others here have pointed out), the mathematical properties >> of the greatest common divisor are well defined for both positive and >> negative integers. > > You keep saying that, but it simply is not true. Different people use > di

Re: GCD in Fractions

2014-09-24 Thread Terry Reedy
On 9/24/2014 7:44 AM, Steven D'Aprano wrote: blindanagram wrote: Seccondly (as others here have pointed out), the mathematical properties of the greatest common divisor are well defined for both positive and negative integers. You keep saying that, but it simply is not true. Different people

Re: GCD in Fractions

2014-09-24 Thread blindanagram
On 24/09/2014 17:34, Mark Lawrence wrote: > On 24/09/2014 12:14, Mark Dickinson wrote: >> Mark Lawrence yahoo.co.uk> writes: >>> Somebody got there first http://bugs.python.org/issue22477 >> >> I think there's good reason to suspect that Brian Gladman and >> blindanagram are one and the same. :-)

Re: GCD in Fractions

2014-09-24 Thread blindanagram
On 24/09/2014 17:13, Stefan Behnel wrote: > blindanagram schrieb am 24.09.2014 um 15:25: >> On 24/09/2014 12:44, Steven D'Aprano wrote: [snip] > We have an open tracker ticket now on changing *something* about the > current situation. Let's just add some new functionality somewhere if > people re

Re: GCD in Fractions

2014-09-24 Thread random832
On Wed, Sep 24, 2014, at 10:26, Ian Kelly wrote: > This depends entirely on your implementation of the modulo operation, > which is an issue of computing since the operator is not used in > mathematics. Wikipedia suggests that "remainders from Euclidean division" should be used. In Euclidean divis

Re: GCD in Fractions

2014-09-24 Thread Mark Lawrence
On 24/09/2014 12:14, Mark Dickinson wrote: Mark Lawrence yahoo.co.uk> writes: Somebody got there first http://bugs.python.org/issue22477 I think there's good reason to suspect that Brian Gladman and blindanagram are one and the same. :-) sorted("BrianGladman".lower()) == sorted("blindanagra

Re: GCD in Fractions

2014-09-24 Thread Stefan Behnel
blindanagram schrieb am 24.09.2014 um 15:25: > On 24/09/2014 12:44, Steven D'Aprano wrote: > >> blindanagram wrote: > [snip] >> - Mathworld says that GCD of two negative numbers is a negative number; >> >> - but Mathematica says that GCD of two negative numbers is a positive; >> >> - Wikipedia agr

Re: GCD in Fractions

2014-09-24 Thread Ian Kelly
On Wed, Sep 24, 2014 at 5:44 AM, Steven D'Aprano wrote: > The Collins Dictionary of Mathematics (second edition, 2002) says: > > highest common factor, greatest common factor, or greatest > common divisor (abbrev hcf, gcf, gcd) > > n, an integer d that exactly divides (sense 2) two giv

Re: GCD in Fractions

2014-09-24 Thread blindanagram
On 24/09/2014 12:44, Steven D'Aprano wrote: > blindanagram wrote: [snip] > - Mathworld says that GCD of two negative numbers is a negative number; > > - but Mathematica says that GCD of two negative numbers is a positive; > > - Wikipedia agrees with Mathematica and disagrees with Mathworld; Aft

Re: GCD in Fractions

2014-09-24 Thread Steven D'Aprano
blindanagram wrote: > Seccondly (as others here have pointed out), the mathematical properties > of the greatest common divisor are well defined for both positive and > negative integers. You keep saying that, but it simply is not true. Different people use different definitions. Some refuse to a

Re: GCD in Fractions

2014-09-24 Thread Mark Dickinson
Mark Lawrence yahoo.co.uk> writes: > Somebody got there first http://bugs.python.org/issue22477 I think there's good reason to suspect that Brian Gladman and blindanagram are one and the same. :-) >>> sorted("BrianGladman".lower()) == sorted("blindanagram") True -- https://mail.python.o

Re: GCD in Fractions

2014-09-24 Thread Mark Lawrence
On 23/09/2014 23:52, Mark Lawrence wrote: On 23/09/2014 22:48, blindanagram wrote: On 23/09/2014 20:30, Mark Lawrence wrote: On 23/09/2014 18:43, blindanagram wrote: All you need do is raise an issue on the bug tracker, provide a patch to code, test and docs and the job is done. Thank you for

Re: GCD in Fractions

2014-09-23 Thread Mark Lawrence
On 23/09/2014 22:48, blindanagram wrote: On 23/09/2014 20:30, Mark Lawrence wrote: On 23/09/2014 18:43, blindanagram wrote: On 23/09/2014 18:26, Stefan Behnel wrote: Wolfgang Maier schrieb am 23.09.2014 um 18:38: While at first I thought this to be a rather irrelevant debate over module priva

Re: GCD in Fractions

2014-09-23 Thread blindanagram
On 23/09/2014 20:30, Mark Lawrence wrote: > On 23/09/2014 18:43, blindanagram wrote: >> On 23/09/2014 18:26, Stefan Behnel wrote: >>> Wolfgang Maier schrieb am 23.09.2014 um 18:38: While at first I thought this to be a rather irrelevant debate over module private vs public naming con

Re: GCD in Fractions

2014-09-23 Thread blindanagram
On 23/09/2014 18:55, Stefan Behnel wrote: > blindanagram schrieb am 23.09.2014 um 19:43: >> On 23/09/2014 18:26, Stefan Behnel wrote: >>> Wolfgang Maier schrieb am 23.09.2014 um 18:38: While at first I thought this to be a rather irrelevant debate over module private vs public naming conv

Re: GCD in Fractions

2014-09-23 Thread Terry Reedy
On 9/23/2014 4:16 AM, blindanagram wrote: What is the rationale for gcd(x, y) in Fractions returning a negative value when y is negtive? For example gcd(3, -7) returns -1, Since the doc says "the result will have the same sign as b", this is intentinal. However, I consider this a *design*

Re: GCD in Fractions

2014-09-23 Thread Mark Lawrence
On 23/09/2014 18:43, blindanagram wrote: On 23/09/2014 18:26, Stefan Behnel wrote: Wolfgang Maier schrieb am 23.09.2014 um 18:38: While at first I thought this to be a rather irrelevant debate over module private vs public naming conventions, I now think the OP is probably right and renaming fr

Re: GCD in Fractions

2014-09-23 Thread Stefan Behnel
Ian Kelly schrieb am 23.09.2014 um 19:39: > On Tue, Sep 23, 2014 at 11:26 AM, Stefan Behnel wrote: >> Wolfgang Maier schrieb am 23.09.2014 um 18:38: >>> While at first I thought this to be a rather irrelevant debate over module >>> private vs public naming conventions, I now think the OP is probabl

Re: GCD in Fractions

2014-09-23 Thread Stefan Behnel
blindanagram schrieb am 23.09.2014 um 19:43: > On 23/09/2014 18:26, Stefan Behnel wrote: >> Wolfgang Maier schrieb am 23.09.2014 um 18:38: >>> While at first I thought this to be a rather irrelevant debate over module >>> private vs public naming conventions, I now think the OP is probably right >>

Re: GCD in Fractions

2014-09-23 Thread Ian Kelly
On Tue, Sep 23, 2014 at 11:39 AM, Ian Kelly wrote: > I'm not convinced it's all that clear. In addition to Mathworld and > Wikipedia that were already cited, ProofWiki provides an actual proof > that gcd(a, b) = gcd(|a|, |b|), by way of noting that a and |a| have > the same factors. I forgot to i

Re: GCD in Fractions

2014-09-23 Thread blindanagram
On 23/09/2014 18:26, Stefan Behnel wrote: > Wolfgang Maier schrieb am 23.09.2014 um 18:38: >> While at first I thought this to be a rather irrelevant debate over module >> private vs public naming conventions, I now think the OP is probably right >> and renaming fractions.gcd to fractions._gcd may

Re: GCD in Fractions

2014-09-23 Thread Ian Kelly
On Tue, Sep 23, 2014 at 11:26 AM, Stefan Behnel wrote: > Wolfgang Maier schrieb am 23.09.2014 um 18:38: >> While at first I thought this to be a rather irrelevant debate over module >> private vs public naming conventions, I now think the OP is probably right >> and renaming fractions.gcd to fract

Re: GCD in Fractions

2014-09-23 Thread blindanagram
On 23/09/2014 18:20, Ian Kelly wrote: > On Tue, Sep 23, 2014 at 10:38 AM, Wolfgang Maier > wrote: >> Maybe fractions.gcd could be renamed, but be wrapped or reimplemented >> correctly somewhere else in the stdlib or even in fractions ? > > +1 > > I don't think the math module as suggested upthre

Re: GCD in Fractions

2014-09-23 Thread Stefan Behnel
Wolfgang Maier schrieb am 23.09.2014 um 18:38: > While at first I thought this to be a rather irrelevant debate over module > private vs public naming conventions, I now think the OP is probably right > and renaming fractions.gcd to fractions._gcd may be a good idea. Making a public API private is

Re: GCD in Fractions

2014-09-23 Thread Ian Kelly
On Tue, Sep 23, 2014 at 10:38 AM, Wolfgang Maier wrote: > Maybe fractions.gcd could be renamed, but be wrapped or reimplemented > correctly somewhere else in the stdlib or even in fractions ? +1 I don't think the math module as suggested upthread is the right place, as that module houses wrapper

Re: GCD in Fractions

2014-09-23 Thread Wolfgang Maier
On 09/23/2014 02:50 PM, Steven D'Aprano wrote: Normally, gcd is only defined for non-negative integers. Wolfram Mathworld, for example, doesn't mention negative values at all (as far as I can see): http://mathworld.wolfram.com/GreatestCommonDivisor.html although buried deep in the documentatio

Re: GCD in Fractions

2014-09-23 Thread Chris Angelico
On Wed, Sep 24, 2014 at 12:37 AM, blindanagram wrote: > That's an argument for a private gcd within the fractions module and a a > 'normal' version in math. Steven's examples show that there's not really much definition of "normal" as regards GCD of negative numbers. ChrisA -- https://mail.pyth

Re: GCD in Fractions

2014-09-23 Thread blindanagram
On 23/09/2014 13:50, Steven D'Aprano wrote: > blindanagram wrote: > >> What is the rationale for gcd(x, y) in Fractions returning a negative >> value when y is negtive? > > Good question. > > Normally, gcd is only defined for non-negative integers. Wolfram Mathworld, > for example, doesn't menti

Re: GCD in Fractions

2014-09-23 Thread Steven D'Aprano
blindanagram wrote: > What is the rationale for gcd(x, y) in Fractions returning a negative > value when y is negtive? Good question. Normally, gcd is only defined for non-negative integers. Wolfram Mathworld, for example, doesn't mention negative values at all (as far as I can see): http://mat

Re: GCD in Fractions

2014-09-23 Thread blindanagram
On 23/09/2014 12:53, Wolfgang Maier wrote: > On 09/23/2014 10:16 AM, blindanagram wrote: >> What is the rationale for gcd(x, y) in Fractions returning a negative >> value when y is negtive? >> > > I guess it is implemented this way because its main use is in the > Fraction constructor. This is no

Re: GCD in Fractions

2014-09-23 Thread Wolfgang Maier
On 09/23/2014 10:16 AM, blindanagram wrote: What is the rationale for gcd(x, y) in Fractions returning a negative value when y is negtive? I guess it is implemented this way because its main use is in the Fraction constructor. For example gcd(3, -7) returns -1, which means that a co-prime