Le samedi 22 octobre 2011 à 11:05 +0530, Hector a écrit : > > > On Fri, Oct 21, 2011 at 3:49 PM, Chris Smith <smi...@gmail.com> wrote: > I just noticed in Integer, too, the invert method which gives > the > multiplicative inverse mode n of a number: > > >>> invert(S(3),5) > 2 > >>> (3*2)%5 == 1 > True > >>> invert(S(4),6) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > > File "sympy\polys\polytools.py", line 4249, in invert > return f.invert(g) > File "sympy\core\numbers.py", line 1322, in invert > raise ZeroDivisionError("zero divisor") > ZeroDivisionError: zero divisor > > > Before tackling this problem, we need to answer - is ``invert`` (or > inverse in finite field) in its present form valid?? > > In [39]: FF? > Docstring : > Finite field based on Python's integers. > > In [40]: FF(4) > Out[40]: ℤ₄ > > But FF(4) fails to be a field [0]. Multiplication is not well defined. > This thing is not highlighted by sympy
But mathematically, FF(4) exists and is a field. However, FF(4) != ZZ_4. > I second Aaron's suggestions of making class FiniteRing and put more > constrains on FintiteField. So, the output **would** be something > like FiniteRing isn't a good name, because there can be many finite rings of a given order. "CyclicRing" or "CongruenceRing" would be unambiguous. > > >>> FF(4) > Error - Z4 is not a filed > > >>> FR(4) > Z4 > > >>> FR(4)(3).invert() > 1 ## Additive inverse > > >>> FF(5) > Z5 > > >>> FF(5)(4).invert_mul() > 4 > > >>> FF(5)(4).invert_add() > 1 > > > > To find an Integer given a description of it's modulus profile > perhaps > a method "from_moduli" could be added so > Integer.from_moduli((2, 3), > (3, 5)) would give 8. Hector, Mateusz, anyone else: does that > look > like a good way to construct it? Is there a better method > name? That's the Chinese remainder problem[1]. The solution isn't unique so I don't think this should be a classmethod of Integer. [1]: http://en.wikipedia.org/wiki/Chinese_remainder_theorem -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.