login  home  contents  what's new  discussion  bug reports help  links  subscribe  changes  refresh  edit

fricas
R := Integer
 (1)
Type: Type
fricas
Q := Fraction R
 (2)
Type: Type
fricas
gcd(8,4) = retract gcd(8::Q, 4::Q)
 (3)
Type: Equation(PositiveInteger?)

fricas
a:=13/6
 (4)
Type: Fraction(Integer)
fricas
b:=3/4
 (5)
Type: Fraction(Integer)

fricas
g:=gcd(a,b)
 (6)
Type: Fraction(Integer)
fricas
l:=lcm(a,b)
 (7)
Type: Fraction(Integer)
fricas
g*l = a*b
 (8)
Type: Equation(Fraction(Integer))

fricas
gcd2(x:Q,y:Q):Q == gcd(retract numerator x, retract numerator y)$R / lcm(retract denominator x, retract denominator y)$R
Function declaration gcd2 : (Fraction(Integer), Fraction(Integer))
-> Fraction(Integer) has been added to workspace.
Type: Void
fricas
lcm2(x:Q,y:Q):Q == lcm(retract numerator x, retract numerator y)$R / gcd(retract denominator x, retract denominator y)$R
Function declaration lcm2 : (Fraction(Integer), Fraction(Integer))
-> Fraction(Integer) has been added to workspace.
Type: Void

fricas
g:=gcd2(a,b)
fricas
Compiling function gcd2 with type (Fraction(Integer), Fraction(
Integer)) -> Fraction(Integer)
 (9)
Type: Fraction(Integer)
fricas
l:=lcm2(a,b)
fricas
Compiling function lcm2 with type (Fraction(Integer), Fraction(
Integer)) -> Fraction(Integer)
 (10)
Type: Fraction(Integer)
fricas
g*l = a*b
 (11)
Type: Equation(Fraction(Integer))

fricas
gcd3(x:Q,y:Q):Q == gcd(retract numerator x * retract denominator y, retract numerator y * retract denominator x)$R / (retract denominator x * retract denominator y)$R
Function declaration gcd3 : (Fraction(Integer), Fraction(Integer))
-> Fraction(Integer) has been added to workspace.
Type: Void
fricas
lcm3(x:Q,y:Q):Q == lcm(retract numerator x * retract denominator y, retract numerator y * retract denominator x)$R / (retract denominator x * retract denominator y)$R
Function declaration lcm3 : (Fraction(Integer), Fraction(Integer))
-> Fraction(Integer) has been added to workspace.
Type: Void

fricas
g:=gcd3(a,b)
fricas
Compiling function gcd3 with type (Fraction(Integer), Fraction(
Integer)) -> Fraction(Integer)
 (12)
Type: Fraction(Integer)
fricas
l:=lcm3(a,b)
fricas
Compiling function lcm3 with type (Fraction(Integer), Fraction(
Integer)) -> Fraction(Integer)
 (13)
Type: Fraction(Integer)
fricas
g*l = a*b
 (14)
Type: Equation(Fraction(Integer))

fricas
gcd2(0,0)
 (15)
Type: Fraction(Integer)
fricas
lcm2(0,0)
 (16)
Type: Fraction(Integer)

gcd in fraction fields thread --Bill Page, Tue, 23 May 2017 20:22:26 +0000 reply
Ralf suggested this version:

fricas
fractionGcd(x,y) == gcd(numer x, numer y) / lcm(denom x, denom y)
Type: Void
fricas
a:=13/6
 (17)
Type: Fraction(Integer)
fricas
b:=3/4
 (18)
Type: Fraction(Integer)
fricas
fractionGcd(a,b)
fricas
Compiling function fractionGcd with type (Fraction(Integer),
Fraction(Integer)) -> Fraction(Integer)
 (19)
Type: Fraction(Integer)

 Subject: (replying)   Be Bold !! ( 15 subscribers )