Dear everyone, hi. I have tried to calculate the greatest common divisor of the three following monomials:
12a^3b^2c^2, 6a^2b^3c^3, 3a^2b^2c^3.
In order to do this I have written:
gcd(12a^3b^2c^2, 6a^2b^3c^3, 3a^2b^2*c^3);
but Maxima gives me the result "6a^2b^2c^2" instead of "3a^2b^2c^2". What is the point?
I think you're using gcd wrong. The manual for gcd (via "? gcd") says:
so it only takes two polynomials. It doesn't describe what
x_1
is, though and I don't really know either.As Ray says,
gcd
takes two polynomials. Arguments x_1, x_2, etc. specify the variable ordering (cf.ratvars
anddivide
, which also takes x_n arguments). I agree that the doc should be explicit about this.For the gcd of more than two polynomials, here's an easy approach:
Ok, many thanks to both of you. So I can either use nested gcd calls
gcd(12a^3b^2c^2, gcd(6a^2b^3c^3, 3a^2b^2c^3))
or use the xreduce function with gcd. I think it could be more intuitive to let gcd function to take more than two polynomials.
Best regards.
I understand your point. But that leaves the question of how to specify
variable order.
Fateman, can you supply an example where the result is non-trivially
different with different variable order? (not just x-y vs y-x).
On Thu, Dec 28, 2023 at 12:41 PM Emanuele Giusti via Maxima-bugs maxima-bugs@lists.sourceforge.net wrote:
Related
Bugs:
#4231Hi. I do not understand what you mean and I do not understand the meaning of the word "Fateman". I am not an english native speaker. The dictionary does not provide any translation for that word. I am a new Maxima user. I do not want to make a controversy. Of course Maxima has an algorithm to calculate the gcd of two polynomials; maybe it could be possible to extend the funtionality of that algorithm to deal with more than two polynomials. For me it is fine to use the two solutions you have provided to me, what I have said is only a suggestion.
I think what Stavros is saying is that if you change gcd to have more then two polynomials then how do you know what the last polynomial is and where the x_1 argument begins. That is, gcd has no way of knowing if you want gcd(p1,p2,p3, x1) to do 3 polynomials or if p3 is another ratvar polynomial for ordering.
"Fateman" is a reference to Richard Fateman, one of the original Macsyma authors who still contributes to Maxima.
You can also package the functionality so that it's easy to use:
gcdn([l]) := xreduce('gcd, l)$
It is rare that you'll need to specify the main variable -- which as far as
I can tell only determines whether there is a factor of -1:
makelist( gcd (x^2-y^2, x-y,x),
gcd,'[ez,subres,red,spmod]);
=> [x - y, x - y, x - y, x - y]
makelist( gcd (x^2-y^2, x-y,y),
gcd,'[ez,subres,red,spmod]);
=> [y - x, y - x, y - x, y - x]
and the exact form of the result:
qq;
2 2 2 2 2 2
y z - x z - y z + x z + x y - x y
rr;
(y - z) (z - x)
gcd(qq,rr,x,y,z);
2
z + ((- y) - x) z + x y
gcd(qq,rr,x,z,y);
2
(- z ) + y (z - x) + x z
gcd(qq,rr,y,x,z);
2
z + ((- y) - x) z + x y
gcd(qq,rr,y,z,x);
2
(- z ) + x (z - y) + y z
gcd(qq,rr,z,x,y);
2
z - x z + y (x - z)
gcd(qq,rr,z,y,x);
2
z - y z + x (y - z)
On Thu, Dec 28, 2023 at 12:41 PM Emanuele Giusti rayon340@users.sourceforge.net wrote:
Related
Bugs:
#4231see gcd ( (x+y+1)^2, (x+y+1)^3,x,y);
vs
gcd((x+y+1)^2,(x+y+1)^3, y,x);
to see what the extra arguments do.
Richard Fateman ;)
Last edit: Richard Fateman 2023-12-30
Here is a minimum example of the sign of the result being different because of variable ordering: