Open rtoy opened 4 months ago
Imported from SourceForge on 2024-07-09 11:20:52 Created by rtoy on 2023-12-28 17:21:34 Original: https://sourceforge.net/p/maxima/bugs/4231/#e575
I think you're using gcd wrong. The manual for gcd (via "? gcd") says:
-- Function: gcd (
, , , ...) Returns the greatest common divisor of and . The flag
so it only takes two polynomials. It doesn't describe what x_1
is, though and I don't really know either.
Imported from SourceForge on 2024-07-09 11:20:55 Created by macrakis on 2023-12-28 17:34:11 Original: https://sourceforge.net/p/maxima/bugs/4231/#6a60
As Ray says, gcd
takes two polynomials. Arguments x_1, x_2, etc. specify the variable ordering (cf. ratvars
and divide
, 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:
xreduce('gcd,[12*a^3*b^2*c^2, 6*a^2*b^3*c^3,3*a^2*b^2*c^3]);
=> 3*a^2*b^2*c^2
Imported from SourceForge on 2024-07-09 11:20:59 Created by rayon340 on 2023-12-28 17:41:19 Original: https://sourceforge.net/p/maxima/bugs/4231/#daf7
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.
Imported from SourceForge on 2024-07-09 11:21:02 Created by macrakis on 2023-12-28 19:34:19 Original: https://sourceforge.net/p/maxima/bugs/4231/#daf7/0433
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:
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.
[bugs:#4231] https://sourceforge.net/p/maxima/bugs/4231/ Greatest common divisor wrong result
Status: not-a-bug Group: None Labels: greatest common divisor gcd Created: Thu Dec 28, 2023 05:10 PM UTC by Emanuele Giusti Last Updated: Thu Dec 28, 2023 05:34 PM UTC Owner: nobody
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^2 c^2". What is the point?
Sent from sourceforge.net because maxima-bugs@lists.sourceforge.net is subscribed to https://sourceforge.net/p/maxima/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/maxima/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Maxima-bugs mailing list Maxima-bugs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/maxima-bugs
Attachments:
Imported from SourceForge on 2024-07-09 11:21:06 Created by rayon340 on 2023-12-28 19:55:17 Original: https://sourceforge.net/p/maxima/bugs/4231/#daf7/0433/5ecf
Hi. 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.
Imported from SourceForge on 2024-07-09 11:21:09 Created by rtoy on 2023-12-29 00:39:39 Original: https://sourceforge.net/p/maxima/bugs/4231/#daf7/0433/5ecf/6592
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.
Imported from SourceForge on 2024-07-09 11:21:13 Created by macrakis on 2023-12-29 15:37:17 Original: https://sourceforge.net/p/maxima/bugs/4231/#daf7/0630
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:
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.
[bugs:#4231] https://sourceforge.net/p/maxima/bugs/4231/ Greatest common divisor wrong result
Status: not-a-bug Group: None Labels: greatest common divisor gcd Created: Thu Dec 28, 2023 05:10 PM UTC by Emanuele Giusti Last Updated: Thu Dec 28, 2023 05:34 PM UTC Owner: nobody
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^2 c^2". What is the point?
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/maxima/bugs/4231/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
Attachments:
Imported from SourceForge on 2024-07-09 11:21:17 Created by fateman on 2023-12-29 23:04:27 Original: https://sourceforge.net/p/maxima/bugs/4231/#298f
see 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 ;)
Imported from SourceForge on 2024-07-09 11:21:20 Created by macrakis on 2023-12-30 00:00:53 Original: https://sourceforge.net/p/maxima/bugs/4231/#2cb3
Here is a minimum example of the sign of the result being different because of variable ordering:
gcd(x-y,y-x,x) => x - y
gcd(x-y,y-x,y) => y - x
Imported from SourceForge on 2024-07-09 11:20:50 Created by rayon340 on 2023-12-28 17:10:23 Original: https://sourceforge.net/p/maxima/bugs/4231
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?