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

## GCD and types

Types help to make it clear where the computation happens.

fricas
P(R,x)==>UnivariatePolynomial(x,R);
Type: Void
fricas
Z==>Integer;
Type: Void
fricas
Q==>Fraction Z;
Type: Void

Now we compute the gcd in

fricas
p11: P(P(Z, x), y) := 12*x^2*y;
fricas
p12: P(P(Z, x), y) := 18*x*y^2;
fricas
gcd(p11, p12)
 (1)

Now in

fricas
p21: P(P(Q, x), y) := 12*x^2*y;
Type: UnivariatePolynomial(y,UnivariatePolynomial(x,Fraction(Integer)))
fricas
p22: P(P(Q, x), y) := 18*x*y^2;
Type: UnivariatePolynomial(y,UnivariatePolynomial(x,Fraction(Integer)))
fricas
gcd(p21, p22)
 (2)
Type: UnivariatePolynomial(y,UnivariatePolynomial(x,Fraction(Integer)))

In

fricas
p31: P(Fraction P(Q, x), y) := 12*x^2*y;
Type: UnivariatePolynomial(y,Fraction(UnivariatePolynomial(x,Fraction(Integer))))
fricas
p32: P(Fraction P(Q, x), y) := 18*x*y^2;
Type: UnivariatePolynomial(y,Fraction(UnivariatePolynomial(x,Fraction(Integer))))
fricas
gcd(p31, p32)
 (3)
Type: UnivariatePolynomial(y,Fraction(UnivariatePolynomial(x,Fraction(Integer))))

And finally in the field

fricas
p41: Fraction P(P(Q, x), y) := 12*x^2*y;
Type: Fraction(UnivariatePolynomial(y,UnivariatePolynomial(x,Fraction(Integer))))
fricas
p42: Fraction P(P(Q, x), y) := 18*x*y^2;
Type: Fraction(UnivariatePolynomial(y,UnivariatePolynomial(x,Fraction(Integer))))
fricas
gcd(p41, p42)
 (4)
Type: Fraction(UnivariatePolynomial(y,UnivariatePolynomial(x,Fraction(Integer))))

 Subject:   Be Bold !! ( 15 subscribers )