Closed malb closed 15 years ago
The patch fixes the exception, however:
sage: sage: R.<x,y> = CC[]
sage: sage: I = R.ideal(x^2+y^2-1,x*y-1)
sage: sage: I.variety()
verbose 0 (1735: multi_polynomial_ideal.py, variety) Warning: falling back to very slow toy implementation.
[{y: -1.00000000000000}, {y: 0}, {y: 1.00000000000000}]
which is certainly the wrong answer (x
is missing), thus there seems to be another bug.
It seems toy_variety
does not switch to 'lex' when it should?
Attachment: toy_variety_fix.patch.gz
The attached patch switches to lex before calling toy_variety.triangular_factorization
Two issues:
in the first patch, "proofably" should be "provably"
I'm getting some slight numerical noise in the doctests from the second patch:
sage -t "devel/sage-main/sage/rings/polynomial/multi_polynomial_ideal.py"
**********************************************************************
File "/opt/sage-devel/devel/sage-main/sage/rings/polynomial/multi_polynomial_ideal.py", line 1908:
sage: for v in I.variety():
print v
Expected:
verbose 0 (...: multi_polynomial_ideal.py, variety) Warning: falling back to very slow toy implementation.
{y: -0.866025403784439 - 0.500000000000000*I, x: -0.866025403784438 + 0.500000000000000*I}
{y: -0.866025403784438 + 0.500000000000000*I, x: -0.866025403784438 - 0.499999999999999*I}
{y: 0.866025403784438 + 0.500000000000001*I, x: 0.866025403784440 - 0.499999999999999*I}
{y: 0.866025403784439 - 0.500000000000000*I, x: 0.866025403784439 + 0.500000000000000*I}
Got:
verbose 0 (1735: multi_polynomial_ideal.py, variety) Warning: falling back to very slow toy implementation.
{y: -0.866025403784439 - 0.500000000000000*I, x: -0.866025403784439 + 0.500000000000001*I}
{y: -0.866025403784439 + 0.500000000000000*I, x: -0.866025403784439 - 0.500000000000000*I}
{y: 0.866025403784438 + 0.500000000000000*I, x: 0.866025403784438 - 0.499999999999999*I}
{y: 0.866025403784439 - 0.500000000000000*I, x: 0.866025403784438 + 0.500000000000001*I}
**********************************************************************
1 items had failures:
1 of 36 in __main__.example_34
***Test Failed*** 1 failures.
For whitespace errors, see the file /opt/sage-devel/tmp/.doctest_multi_polynomial_ideal.py
[12.8 s]
exit code: 1024
----------------------------------------------------------------------
The following tests failed:
sage -t "devel/sage-main/sage/rings/polynomial/multi_polynomial_ideal.py"
Total time for all tests: 12.8 seconds
Wrong milestone - better luck in Sage 4.0.
Cheers,
Michael
fix typo
Attachment: mpoly_factor_proof.patch.gz
I fixed the "proofable" vs. "provable" typo. However, I am a bit clueless how to deal with the numerical noise. The ...
works for most of it but not for 0.49999999999
vs. {{{0.500000000}}. Ideas?
Martin,
Sorry for the late reply, but according to Lazard's paper, the algorithm I used ("Triangular") does NOT need a lexicographic term ordering. On p. 124, beginning of Section 6:
These algorithms do not depend explicitly on the ordering; however, they are mainly designed for degree orderings for which the base is more easily obtained; they work also for lexicographic ordering, but, for them, we dispose of a structure theorem which permit us to provide a better algorithm (section 8).
The algorithm I implemented was Triangular (line 6). So the switch the lexicographic is unnecessary.
I don't know how to fix the problem with complex coefficients, though.
Incidentally, I'll look at the problem with the missing x as soon as I finish downloading & compiling the latest Sage. (4.1.1?)
I have found two bugs. One of them is not solvable from my end, and possibly not at all (others who know more should comment).
The first one: elim_pol is not always computing the correct polynomial. After removing the switch to lexicographic order, change line 358 (?) of toy_variety.py from
for each in xrange(len(coeffs)-1):
to
for each in xrange(len(coeffs)):
I have no idea why I had it count until the next-to-last element of coeffs; all of them are necessary. I can submit a patch if you like.
However: even after this fix, a problem remains: line 292 (?) triangular_factorization tries to compute a Groebner basis of an ideal whose generators should have a common solution. This is the source of the 1.0 appearing in the triangular variety. Unfortunately, the computed basis is 1.0, suggesting that the ideal has no common solution! I have an idea why this is happening, but I can't yet say for sure.
To follow up, the problem occurs when computing the Groebner basis over CC.
I'll use the example given:
The Groebner basis computed is [y^3 + x - y, x^2 + y^2 - 1.00000000000000, x*y - 1.00000000000000].
The result p from elim_pol is y^4 - y^2 + 1.0. (This reflects the bugfix I identified above; it used to return y4-y2.)
The first factor q of p is y - 0.866025403784439 - 0.500000000000000*I.
The reduction of B modulo q gives us
[x - 0.866025403784438 + 0.500000000000001I, x^2 - 0.499999999999999 + 0.866025403784439I, (0.866025403784439 + 0.500000000000000I)x - 1.00000000000000]
This should be a consistent system: the first polynomial is a factor of the second, and the solution to the third is nearly the same as the solution to the first: 0.866025403784438 - 0.500000000000001I vs. 0.866025403784438 - 0.500000000000000I. This appears to be a roundoff/floating point error.
The system above should produce a Groebner basis with one polynomial, but it returns [1.00000000000000] instead. This is why nothing is coming back for x. Anyone know how to fix it?
Sorry for the repost, but I had some superscript typos in the previou.
To follow up, the problem occurs when computing the Groebner basis over CC.
I'll use the example given:
The Groebner basis computed is [y3 + x - y, x2 + y*2 - 1.00000000000000, xy - 1.00000000000000].
The result p from elim_pol is y4 - y2 + 1.0. (This reflects the bugfix I identified above; it used to return y4-y2.)
The first factor q of p is y - 0.866025403784439 - 0.500000000000000*I.
The reduction of B modulo q gives us
[x - 0.866025403784438 + 0.500000000000001*I, x*2 - 0.499999999999999 + 0.866025403784439I, (0.866025403784439 + 0.500000000000000I)x - 1.00000000000000]
This should be a consistent system: the first polynomial is a factor of the second, and the solution to the third is nearly the same as the solution to the first: 0.866025403784438 - 0.500000000000001I vs. 0.866025403784438 - 0.500000000000000I. This appears to be a roundoff/floating point error.
The system above should produce a Groebner basis with one polynomial, but it returns [1.00000000000000] instead. This is why nothing is coming back for x. Anyone know how to fix it?
Well, we should probably just disallow computing a GB over CC anyway, it doesn't really make sense because CC is not realy a field.
You mean CC as implemented, not CC in theory?
I could insert a test for whether the field is CC, and if so raise an exception. That said, the roots we're looking for are algebraic, and so can be described symbolically; i.e., without floating point. So if the polynomial starts from QQ, one could in theory construct the roots. Should the exception just reject the user's input, advise the user to try an extension field, or try to construct one itself?
Is this something I should ask about on sage-devel?
Yes, I mean fixed precision floating point numbers. We could just print a warning? Even if the solutions are algebraic the rounding errors can cause a zero to look like a one.
Attachment: variety_CC.patch.gz
The uploaded patch should incorporate Martin's changes and should also provide a warning if the field is CC. I'd still like to find a way to make it work in CC, though.
The patch looks good, applies cleanly against 4.1.1 and doctests pass on 64-bit Linux (sage.math). There might be a numerical noise issue (see above) which needs to be addressed.
Ah, the doctest needs a ::
prepended otherwise, it won't be run.
which doctest? are you talking about line 1848 of multi_polynomial_ideal.py?
Yes, the doctest starting at 1851.
apply over variety_CC.patch
Attachment: variety_CC2.patch.gz
Okay, double colons on that file. They aren't prepended to the example, though; they appear at the end of line 1849 in the same way as at the end of 1831.
PLEASE tell me this is okay now. Fixing this drove me crazy with hg...
Yes, thats correct this way. However, I expect the doctest will now fail on 32-bit systems (it wasn't run before).
I believe that my system is running as a 32-bit system. I know that Linux is running as 32-bit; does sage run differently?
No, if your Linux is 32-bit then your Sage is 32-bit :)
still no positive review then? :-( what's still needed?
Sorry, here we go.
Which patches should be applied and in what order? The patch variety_CC.patch
contains all changes made in mpoly_factor_proof.patch
. Does that mean mpoly_factor_proof.patch
can be left out?
Indeed, only variety_CC.patch
and variety_CC2.patch
should be applied.
John -- Please remember to put a sensible commit message in your patch. It's recommended that you reference the ticket number in the commit message. Merged patches in this order:
variety_CC.patch
variety_CC2.patch
Reviewer: Martin Albrecht
Merged: Sage 4.1.2.alpha0
Author: John Perry
The parameter should be ignored, but for compatibility it is necessary.
E.g. this should work:
but it raises an except in 3.4.1.
CC: @johnperry-math
Component: commutative algebra
Keywords: singular, factor
Author: John Perry
Reviewer: Martin Albrecht
Merged: Sage 4.1.2.alpha0
Issue created by migration from https://trac.sagemath.org/ticket/5958