Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behavior of gcd over non-prime field #2199

Open
user202729 opened this issue Jan 28, 2025 · 1 comment
Open

Inconsistent behavior of gcd over non-prime field #2199

user202729 opened this issue Jan 28, 2025 · 1 comment

Comments

@user202729
Copy link
Contributor

Currently, over Z/6Z[x], gcd(x, 2) returns 1, while gcd(2x+2, 2x+2) raises exception.

While the documentation states that the result is tried to made monic when possible, I think the former result doesn't exactly make sense, since the ideal (x, 2) in Z/6Z[x] is not equal to the ideal (1).

Besides, the two results are inconsistent with each other.

Example code:

#include <flint/flint.h>
#include <flint/nmod_poly.h>

int main()
{
    nmod_poly_t A, B, G;

    nmod_poly_init(A, 6);
    nmod_poly_init(B, 6);
    nmod_poly_init(G, 6);

	/*
    nmod_poly_set_coeff_ui(A, 1, 1); // A = x
    nmod_poly_set_coeff_ui(B, 0, 2); // B = 2
	*/
    nmod_poly_set_coeff_ui(A, 1, 2); // A = 2*x+2
    nmod_poly_set_coeff_ui(A, 0, 2);
    nmod_poly_set_coeff_ui(B, 1, 2); // B = 2*x+2
    nmod_poly_set_coeff_ui(B, 0, 2);

    nmod_poly_gcd(G, A, B);

    flint_printf("GCD(x, 2) in Z/6Z[x] = ");
    nmod_poly_print_pretty(G, "x");
    flint_printf("\n");

    nmod_poly_clear(A);
    nmod_poly_clear(B);
    nmod_poly_clear(G);

    return 0;
}
@user202729
Copy link
Contributor Author

This is actually harder than it looked, since Euclidean algorithm does not always work over rings.

E.g. gcd(x^2+x, 2*x+1) = 1 since (2*x+1)*(-4*x+1) ≡ 1 (mod x^2+x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant