Opened 8 years ago
Closed 8 years ago
#3124 closed defect (fixed)
[with patch, positive review] bug in solve_mod
Reported by: | was | Owned by: | mhansen |
---|---|---|---|
Priority: | major | Milestone: | sage-3.3 |
Component: | basic arithmetic | Keywords: | |
Cc: | AlexGhitza | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Hi, I think this is a bug. Solving x == y mod 3 works fine: sage: var('x,y') (x, y) sage: solve_mod([x == y], 3) [(0, 0), (1, 1), (2, 2)] But solving mod 2 blows up: sage: solve_mod([x == y], 2) --------------------------------------------------------------------------- <type 'exceptions.TypeError'> Traceback (most recent call last) /home/carlo/work/sagestuff/<ipython console> in <module>() /home/carlo/sage/local/lib/python2.5/site-packages/sage/calculus/equations.py in solve_mod(eqns, modulus) 1339 S = MPolynomialRing(R, len(vars), vars) 1340 eqns_mod = [S(eq) if is_SymbolicExpression(eq) else \ -> 1341 S(eq.lhs() - eq.rhs()) for eq in eqns] 1342 1343 ans = [] /home/carlo/sage/local/lib/python2.5/site-packages/sage/rings/polynomial/multi_polynomial_ring.py in __call__(self, x, check) 380 381 elif hasattr(x, '_polynomial_'): --> 382 return x._polynomial_(self) 383 384 elif isinstance(x, str) and x in self.variable_names(): /home/carlo/sage/local/lib/python2.5/site-packages/sage/calculus/calculus.py in _polynomial_(self, R) 1809 if len(sub) == 0: 1810 try: -> 1811 return R(B(self)) 1812 except TypeError: 1813 if len(vars) == 1: /home/carlo/sage/local/lib/python2.5/site-packages/sage/rings/integer_mod_ring.py in __call__(self, x) 574 def __call__(self, x): 575 try: --> 576 return integer_mod.IntegerMod(self, x) 577 except (NotImplementedError, PariError): 578 return TypeError, "error coercing to finite field" /home/carlo/work/sagestuff/integer_mod.pyx in sage.rings.integer_mod.IntegerMod (sage/rings/integer_mod.c:1731)() /home/carlo/work/sagestuff/integer_mod.pyx in sage.rings.integer_mod.IntegerMod_int.__init__ (sage/rings/integer_mod.c:10153)() /home/carlo/work/sagestuff/integer_ring.pyx in sage.rings.integer_ring.IntegerRing_class.__call__ (sage/rings/integer_ring.c:4473)() <type 'exceptions.TypeError'>: unable to convert x (=x - y) to an integer Any ideas? -- Carlo Hamalainen
Attachments (1)
Change History (8)
comment:1 Changed 8 years ago by
comment:2 Changed 8 years ago by
- Cc AlexGhitza added
comment:3 Changed 8 years ago by
- Owner changed from somebody to mhansen
- Status changed from new to assigned
- Summary changed from bug in solve_mod to [with patch, needs review] bug in solve_mod
This patch also fixes #3125.
Changed 8 years ago by
comment:4 Changed 8 years ago by
comment:5 Changed 8 years ago by
- Summary changed from [with patch, needs review] bug in solve_mod to [with patch, positive review] bug in solve_mod
Looks good to me.
comment:6 Changed 8 years ago by
- Milestone changed from sage-3.4.1 to sage-3.3
comment:7 Changed 8 years ago by
- Resolution set to fixed
- Status changed from assigned to closed
Merged in Sage 3.3.alpha1
Note: See
TracTickets for help on using
tickets.
The underlying issue is that the reprs of the generators of polynomial rings over Z/2Z have minus signs and SymbolicArithmetic?._polynomial_ expects them to not have the signs. I think the appropriate fix would be to fix the printing for the generators of polynomial rings over Z/2Z