Back to Forum | View unanswered posts | View active topics
Topic review - SICA p.9 Exercise 1.1.13. |
Author |
Message |
|
|
Post subject: |
Re: SICA p.9 Exercise 1.1.13. |
|
|
If I type Code: proc zeroFunctions (int p, int d) { option(noredefine); //no unnecessary "redefine f,j,e,k" notifications list l; //list of polynomials for (int i=p^d; i<p^(d+1); i=i+1) { poly f=0; int j,e=i,0; //e is the exponent while(j>0){ f=f+(j%p)*x^e; e=e+1; j=j div p; } int b=1; //boolean expression ’true’ for (int k=0; k<p; k=k+1){ b = b and subst(f,x,k)==0; } //b remains true iff f(k)==0 if (b==1) { l=l+list(f); } } //if f is the zero function, we append it to l return(l); } int p,d=5,6; ring R=p,(x),dp; zeroFunctions(p,d); then Singular returns 20 polynomials, which are all nonzero of degree 6. I don't think there are any duplications. I suspect that you didn't set the ring to ring R=p,(x),dp;. Thank you for your help! regards, Leon
If I type [code]proc zeroFunctions (int p, int d) { option(noredefine); //no unnecessary "redefine f,j,e,k" notifications list l; //list of polynomials for (int i=p^d; i<p^(d+1); i=i+1) { poly f=0; int j,e=i,0; //e is the exponent while(j>0){ f=f+(j%p)*x^e; e=e+1; j=j div p; } int b=1; //boolean expression ’true’ for (int k=0; k<p; k=k+1){ b = b and subst(f,x,k)==0; } //b remains true iff f(k)==0 if (b==1) { l=l+list(f); } } //if f is the zero function, we append it to l return(l); } int p,d=5,6; ring R=p,(x),dp; zeroFunctions(p,d);[/code] then Singular returns 20 polynomials, which are all nonzero of degree 6. I don't think there are any duplications.
I suspect that you didn't set the ring to ring R=p,(x),dp;.
Thank you for your help! regards, Leon
|
|
|
|
Posted: Tue May 07, 2013 2:31 pm |
|
|
|
|
|
Post subject: |
Re: SICA p.9 Exercise 1.1.13. |
|
|
OK; I don't remember what lead me to that apparently false claim.
But I can't see why your code should not work. If I call zeroFunctions (5,6) in char 5, it gives immediately a list with 54 entries.
OK; I don't remember what lead me to that apparently false claim.
But I can't see why your code should not work. If I call zeroFunctions (5,6) in char 5, it gives immediately a list with 54 entries.
|
|
|
|
Posted: Mon May 06, 2013 2:39 pm |
|
|
|
|
|
Post subject: |
Re: SICA p.9 Exercise 1.1.13. |
|
|
How can there be duplications in the list l? Every number j uniquely determines the coefficients of the polynomial f. Here p is assumed to be a prime number.
How can there be duplications in the list l? Every number j uniquely determines the coefficients of the polynomial f. Here p is assumed to be a prime number.
|
|
|
|
Posted: Sat May 04, 2013 3:27 pm |
|
|
|
|
|
Post subject: |
Re: SICA p.9 Exercise 1.1.13. |
|
|
This works correctly for p=2, d=3. I don't know exactly what happens for p=5, d=6. The computer seems to be stuck/frozen. Out of memory? Endless loop? Too long output? Question1: How can I fix my procedure to work flawlessly? Question2: How can I tell Singular not to print every message "redefining b" and "int division", i.e. I'd like to switch to 'silent mode'.[/quote] ad Question2; 1. Singular tells you that you should write Code: j=j div p;
instead of j = j / p; 2. You could surpress the "redefine messages" by setting Code: option(noredefine);
The reason that these messages occur, is that you define local variables inside the nested loops. So better you define at least Code: int j,e,b,k; poly f;
at the very beginning and only set them in the loops. The first for loop you may leave with the declaration as it is Code: for (int i= ) {
}
General remark: Your list will have duplicate entries!
This works correctly for p=2, d=3. I don't know exactly what happens for p=5, d=6. The computer seems to be stuck/frozen. Out of memory? Endless loop? Too long output?
[b]Question1:[/b] How can I fix my procedure to work flawlessly? [b]Question2:[/b] How can I tell Singular not to print every message "redefining b" and "int division", i.e. I'd like to switch to 'silent mode'.[/quote]
ad Question2; 1. Singular tells you that you should write [code] j=j div p; [/code] instead of j = j / p; 2. You could surpress the "redefine messages" by setting [code] option(noredefine); [/code] The reason that these messages occur, is that you define local variables inside the nested loops. So better you define at least [code] int j,e,b,k; poly f; [/code] at the very beginning and only set them in the loops. The first for loop you may leave with the declaration as it is [code] for (int i= ) {
} [/code] General remark: Your list will have duplicate entries!
|
|
|
|
Posted: Thu May 02, 2013 1:50 pm |
|
|
|
|
|
Post subject: |
SICA p.9 Exercise 1.1.13. |
|
|
In A Singular Introduction to Commutative Algebra, the exercise says: "Write a Singular procedure, depending on two integers p, d, with p a prime, which returns all polynomials in F_p[x] of degree d such that the corresponding polynomial function vanishes. Use the procedure to display all f ∈ (Z/5Z)[x] of degree ≤ 6 such that f = 0." My solution: Code: proc zeroFunctions (int p, int d) { list l; //list of polynomials of degree d whose function is zero everywhere for (int i=p^d; i<p^(d+1); i=i+1) //the decimals of i in the numeral system with basis p determine the coefficients of f { poly f=0; int j,e=i,0; //e is the exponent while(j>0){ f=f+(j%p)*x^e; e=e+1; j=j / p; } int b=1; //boolean expression 'true' for (int k=0; k<p; k=k+1) { b = b and subst(f,x,k)==0; } //b remains true if f(j)=0 if (b==1) { l = l + list(f); } //if f is the zero function, we append it to l } return(l);} int p=5; ring R=p,(x),dp; zeroFunctions(p,6); This works correctly for p=2, d=3. I don't know exactly what happens for p=5, d=6. The computer seems to be stuck/frozen. Out of memory? Endless loop? Too long output? Question: How can I fix my procedure to work flawlessly? Question: How can I tell Singular not to print every message "redefining b" and "int division", i.e. I'd like to switch to 'silent mode'.
In [i]A Singular Introduction to Commutative Algebra[/i], the exercise says: "Write a Singular procedure, depending on two integers p, d, with p a prime, which returns all polynomials in F_p[x] of degree d such that the corresponding polynomial function vanishes. Use the procedure to display all f ∈ (Z/5Z)[x] of degree ≤ 6 such that f = 0."
My solution:
[code]proc zeroFunctions (int p, int d) { list l; //list of polynomials of degree d whose function is zero everywhere for (int i=p^d; i<p^(d+1); i=i+1) //the decimals of i in the numeral system with basis p determine the coefficients of f { poly f=0; int j,e=i,0; //e is the exponent while(j>0){ f=f+(j%p)*x^e; e=e+1; j=j / p; } int b=1; //boolean expression 'true' for (int k=0; k<p; k=k+1) { b = b and subst(f,x,k)==0; } //b remains true if f(j)=0 if (b==1) { l = l + list(f); } //if f is the zero function, we append it to l } return(l);} int p=5; ring R=p,(x),dp; zeroFunctions(p,6);[/code]
This works correctly for p=2, d=3. I don't know exactly what happens for p=5, d=6. The computer seems to be stuck/frozen. Out of memory? Endless loop? Too long output?
[b]Question:[/b] How can I fix my procedure to work flawlessly? [b]Question:[/b] How can I tell Singular not to print every message "redefining b" and "int division", i.e. I'd like to switch to 'silent mode'.
|
|
|
|
Posted: Thu May 02, 2013 9:46 am |
|
|
|
|
|
It is currently Fri May 13, 2022 10:58 am
|
|