See http://trac.sagemath.org/ticket/15422. Jeroen and I had a disagreement on what to do in this case, and ended up deciding that we should leave it as an ArithmeticError for now, pending more work on factoring. Brian Sinclair has a patch in progress at http://trac.sagemath.org/ticket/12561 implementing p-adic factoring natively in Sage, though it needs some work.
A degree 2 polynomial over Qp(5), such as f = (1 + O(5^20))*x^2 + O(5^20)*x + O(5^20), can be thought of as a ball inside a three dimensional affine space A over Qp(5) (representing all of the possible polynomials that f approximates). There are various loci inside A corresponding to different factorization patterns (in this case, A has a closed subvariety consisting of reducible polynomials together with its complement consisting of irreducible polynomials; in higher degree there are more options). If you pick one of these loci, the factorization of f is well defined up to a certain precision (see http://arxiv.org/pdf/1402.7142v1.pdf, end of appendix B2). In this case, you get either ((1 + O(5^10))*x + O(5^10))^2 for the reducible locus, (1 + O(5^20))*x^2 + O(5^20)*x + O(5^20) for the irreducible locus. I think the most useful answer is to return ((1 + O(5^10))*x + O(5^10)) * ((1 + O(5^10))*x + O(5^10)) (possibly requiring a certain keyword parameter to the factor method). If your actual polynomial lies in the irreducible locus, it is possible to increase precision enough so that a ball around it lies entirely within the irreducible locus. But if the actual polynomial is reducible, any ball will intersect the irreducible locus. Choosing to raise an error every time you try to factor a non-irreducible polynomial will just cause frustration (as we see here). David On Tue, Apr 28, 2015 at 2:59 PM, Nils Bruin <[email protected]> wrote: > On Tuesday, April 28, 2015 at 11:25:07 AM UTC-7, Joao Alberto de Faria > wrote: >> >> The problem is that this issue also occurs for >> R.<x>=Qp(5)[] >> f=x^2 >> f.factor(), I was trying to fiddle with it and accidently copied the >> wrong code >> > Right. That particular polynomial looks like it can't be confused with an > irreducible one, but that's a special case because its trailing coefficient > is 0, and the code doesn't special case that. But you should really think > of that polynomial as > > sage: f+1-1 > (1 + O(5^20))*x^2 + (O(5^20)) > > which could be an approximation to any one of > > (1 + O(5^40))*x^2 + (-1*5^20+O(5^40)) #which is reducible > (1 + O(5^40))*x^2 + (2*5^20+O(5^40)) #which is irreducible > (1 + O(5^40))*x^2 + (1*5^21+O(5^40)) #which is irreducible for a > different reason > > so if a polynomial isn't obviously square free, deciding its factorization > is numerically unstable. Sage apparently opts to not guess. If you have > reason to believe that you have enough precision to tell the multiplicities > of factors in its factorization then you should proceed exactly as you did: > take the square-free part, factor that, and figure out the multiplicities > of the factors. Sage's reluctance to do that for you is perhaps > inconvienent and possibly not the best user interface choice, but it's > certainly defensible. > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
