Bill Page wrote:
> 
> By default Fraction always returns a gcd of 1.
> 
> (1) -> gcd(1/3,1/4)
> 
>    (1)  1
>                                                       Type: Fraction(Integer)
> 
> But gcd is well defined provided that the underlying domain has GcdDomain.
> 
> diff --git a/src/algebra/fraction.spad b/src/algebra/fraction.spad
> index e42f0da3..fc025a9f 100644
> --- a/src/algebra/fraction.spad
> +++ b/src/algebra/fraction.spad
> @@ -283,6 +283,7 @@ Fraction(S : IntegralDomain) : QuotientFieldCategory S 
> with
>      zero?(x : %) == zero? x.num
> 
>      if S has GcdDomain and S has canonicalUnitNormal then
> +        gcd(x:%,y:%):% == gcd(x.num,y.num)/lcm(x.den,y.den)
>          x = y == (x.num = y.num) and (x.den = y.den)
> 
>          hashUpdate!(s : HashState, x : %) ==
> 
> --
> 
> Is there any good reason why FriCAS should not do this?  Several other
> computer algebra systerms, e.g. Mathematica and Sage implement gcd in
> this way.
> 
> I think it would probably also be good if gcd in Expression where
> defined in this way.

This function could be useful.  But there is problem with current
FriCAS spirit: we have notion of canonical representation of a
prime.  Gcd code take some effort to return canonical version,
which in case of fields means 1.  I am not sure if/what breaks
with changed definition.  In principle the so no warranty for
getting canonocal version, so existing code should work.
But there are many places when we have test for gcd equal to 1.
This code would take different branch with changed definition,
possibly leading to wrong result or loss of efficiency.

As Ralf wrote, your definition is more expensive to compute
than current one.  And depending on need either the current
one (giving canonical version) or new one (extending gcd to
fractions) is more useful.  So it is probably better to have
a separate function, say 'fractionGcd'.

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" 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 https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to