Sorry, I mistakenly attached wrong file. This is the correct one On Sunday, March 31, 2024 at 11:36:25 AM UTC+5:30 Animesh Shree wrote:
> Actually I was facing few errors. > The 4th error made me feel like coercion was required. > > > On Sunday, March 31, 2024 at 3:24:02 AM UTC+5:30 tcscrims wrote: > >> First, coercion is not in any way essential for polynomial rings. It >> makes some things a bit more cumbersome, but it is certainly workable by >> putting elements in the tropical semiring. >> >> Second, the operations between, e.g., integers and tropical ring elements >> does *not* make sense. What is T(1) + 1? Is it 1 or 2? There's no good way >> to answer this. The case with (integer) 0 under addition is a special case >> that I would like to not have, but changing that would be more work than >> the benefit. >> >> Best, >> Travis >> >> >> On Sunday, March 31, 2024 at 6:45:12 AM UTC+9 anime...@iiits.in wrote: >> >>> I read about Matrix Algebra over Tropical Semiring and found that there >>> is "tropical determinant" for this purpose (Page 3 : Eq 4 >>> <http://www.math.uni-konstanz.de/~michalek/may22.pdf>). This >>> formulation does not use (additive) inversion. >>> >>> I was also trying different operations between tropical elements and >>> other elements(like Integers). It looks like there is a need for >>> implementation of coercion maps between few datatypes and tropical >>> elements. >>> One can check this by running few commands like >>> sage: T = TropicalSemiring(QQ) >>> sage: a = T(1); b = T(0) >>> sage: a + 0; b + 0 >>> sage: a * 0; b * 0 >>> sage: a + 1; b + 1 >>> sage: a * 1; b * 1 >>> >>> Coercion maps and models are crucial for polynomial element >>> implementation. >>> For example : between >>> 'Symbolic Ring' and 'Tropical semiring over Rational Field' >>> 'Univariate Polynomial Ring in x over Tropical semiring over Rational >>> Field' and 'Tropical semiring over Rational Field' >>> 'Tropical semiring over Rational Field' and 'Integer Ring' >>> On Friday, March 29, 2024 at 12:16:44 AM UTC+5:30 tcscrims wrote: >>> >>>> One needs to be *very* careful about what operations mean. -T(2), the >>>> (tropical) additive inverse of 2, is *not* T(-2). There is no way to >>>> have min(2, a) = \infty (note that this is the (tropical) additive unit). >>>> >>>> I am not sure how (or if) determinants over the tropical semiring are >>>> defined, but one could define it by having the sign included in each term. >>>> So for the 2x2 case, it could be T(a*b) + T(-b*d), but I don’t know if >>>> this >>>> makes det a group homomorphism. >>>> >>>> Best, >>>> Travis >>>> >>>> >>>> On Wednesday, March 27, 2024 at 2:17:39 AM UTC+9 anime...@iiits.in >>>> wrote: >>>> >>>>> This problem can be seen clearly if we use *Matrix_generic_dense* as >>>>> element class for matrix space. >>>>> >>>>> >>>>> On Tuesday, March 26, 2024 at 9:42:45 PM UTC+5:30 Animesh Shree wrote: >>>>> >>>>>> I was going through this code and got error. But I could not >>>>>> understand why this is the case. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> sage: T = TropicalSemiring(QQ) >>>>>> sage: T(1) >>>>>> 1 >>>>>> sage: T(2) >>>>>> 2 >>>>>> sage: T(-2) >>>>>> -2 >>>>>> sage: -T(2) >>>>>> >>>>>> --------------------------------------------------------------------------- >>>>>> ArithmeticError Traceback (most recent call >>>>>> last) >>>>>> Cell In[26], line 1 >>>>>> ----> 1 -T(Integer(2)) >>>>>> >>>>>> File ~/sage/src/sage/rings/semirings/tropical_semiring.pyx:278, in >>>>>> sage.rings.semirings.tropical_semiring.TropicalSemiringElement.__neg__() >>>>>> 276 if self._val is None: >>>>>> 277 return self >>>>>> --> 278 raise ArithmeticError("cannot negate any non-infinite >>>>>> element") >>>>>> 279 >>>>>> 280 cpdef _mul_(left, right) noexcept: >>>>>> >>>>>> ArithmeticError: cannot negate any non-infinite element >>>>>> sage: >>>>>> >>>>>> >>>>>> It looks like starting with T(-2) and reaching to -2 from T(2) by >>>>>> comparing with zero(+Inf) are different things. >>>>>> T(-2) = -2 >>>>>> T(2) -T(2) = T.zero(+inf) = T(2) + (-T(2)) >>>>>> >>>>>> My doubt is : if we cannot negate the elements, then how can we >>>>>> compute the determinant of a Matrix over Tropical Semiring. >>>>>> For example in 2x2 matrix : [[a,b], [c,d]] the determinant should be >>>>>> ad - bc >>>>>> But can it be expressed as ad + (-bc) -->> min ( add(a,d), >>>>>> -1*add(b,c) )? >>>>>> >>>>>> In fact we connot even do matrix subtraction directly. >>>>>> What can be done in these cases?? >>>>>> On Thursday, March 21, 2024 at 8:48:26 PM UTC+5:30 Animesh Shree >>>>>> wrote: >>>>>> >>>>>>> Hello Sir, >>>>>>> >>>>>>> I have submitted my proposal. >>>>>>> Please review it and let me know necessary updates and improvements. >>>>>>> >>>>>>> I want to verify soundness of my approach and extend the proposal >>>>>>> for Multivariate Polynomials. >>>>>>> >>>>>>> Thank You >>>>>>> Animesh Shree >>>>>>> On Tuesday, March 12, 2024 at 12:26:38 AM UTC+5:30 tcscrims wrote: >>>>>>> >>>>>>>> Mathematically speaking, you can always weaken axioms. However, >>>>>>>> there are some extra advantages that additive groups have that >>>>>>>> commutative >>>>>>>> semirings don't have (mainly 0, the additive identity). >>>>>>>> >>>>>>>> That being said, there isn't anything prevent you from constructing >>>>>>>> the appropriate categories. It would be good to have a more specific >>>>>>>> use-case in mind, but that isn't necessary. However, one should be >>>>>>>> careful >>>>>>>> with the name because it would conflict with what "most" people would >>>>>>>> call >>>>>>>> an algebra (which is why we have MagmaticAlgebras). >>>>>>>> >>>>>>>> Best, >>>>>>>> Travis >>>>>>>> >>>>>>>> >>>>>>>> On Tuesday, March 12, 2024 at 2:57:29 AM UTC+9 anime...@iiits.in >>>>>>>> wrote: >>>>>>>> >>>>>>>>> Hello Sir, >>>>>>>>> >>>>>>>>> I was going through "Algebras" and I had a doubt. >>>>>>>>> Does MagmaticAlgebra and AssociativeAlgebra have to be implemented >>>>>>>>> over Ring only? >>>>>>>>> I went through internet and google uses rings to define those >>>>>>>>> algebras, but the axioms that those algebra follow (Unital, >>>>>>>>> Associative) >>>>>>>>> are also preserved by commutative semirings. >>>>>>>>> Would it be good to define MagmaticAlgebra and AssociativeAlgebra >>>>>>>>> over other objects that follow those axioms too or come-up with >>>>>>>>> alternative >>>>>>>>> Algebra? >>>>>>>>> >>>>>>>> -- You received this message because you are subscribed to the Google Groups "sage-gsoc" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-gsoc+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-gsoc/02ee3c1a-71d3-4701-964b-d60b07848958n%40googlegroups.com.
sage: T = TropicalSemiring(QQ) sage: p = PolynomialRing(T, 'x'); p.element_class <class 'sage.rings.polynomial.polynomial_element.Polynomial_generic_dense'> sage: p(x+1) x + 1 sage: p(x+1)(T(1)) 1 sage: sage: sage: sage: sage: sage: sage: p(x+1)(1) # -----------------------------------Error 1 of 4----------------------------------- --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[26], line 1 ----> 1 p(x+Integer(1))(Integer(1)) File ~/sage/src/sage/rings/polynomial/polynomial_element.pyx:905, in sage.rings.polynomial.polynomial_element.Polynomial.__call__() 903 # This can save lots of coercions when the common parent is the 904 # polynomial's base ring (e.g., for evaluations at integers). --> 905 cst, aa = coercion_model.canonical_coercion(cst, a) 906 # Use fast multiplication actions like matrix × scalar. 907 # If there is no action, replace a by an element of the File ~/sage/src/sage/structure/coerce.pyx:1424, in sage.structure.coerce.CoercionModel.canonical_coercion() 1422 self._record_exception() 1423 -> 1424 raise TypeError("no common canonical parent for objects with parents: '%s' and '%s'"%(xp, yp)) 1425 1426 cpdef coercion_maps(self, R, S) noexcept: TypeError: no common canonical parent for objects with parents: 'Tropical semiring over Rational Field' and 'Integer Ring' sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: p(x+1)(0) # -----------------------------------Error 2 of 4----------------------------------- --------------------------------------------------------------------------- ArithmeticError Traceback (most recent call last) Cell In[25], line 1 ----> 1 p(x+Integer(1))(Integer(0)) File ~/sage/src/sage/rings/polynomial/polynomial_element.pyx:910, in sage.rings.polynomial.polynomial_element.Polynomial.__call__() 908 # target parent. 909 S = parent(aa) --> 910 if coercion_model.get_action(S, R) is None: 911 a = aa 912 R = S File ~/sage/src/sage/structure/coerce.pyx:1759, in sage.structure.coerce.CoercionModel.get_action() 1757 except KeyError: 1758 pass -> 1759 action = self.discover_action(R, S, op, r, s) 1760 action = self.verify_action(action, R, S, op) 1761 self._action_maps.set(R, S, op, action) File ~/sage/src/sage/structure/coerce.pyx:1900, in sage.structure.coerce.CoercionModel.discover_action() 1898 """ 1899 if isinstance(R, Parent): -> 1900 action = (<Parent>R).get_action(S, op, True, r, s) 1901 if action is not None: 1902 return action File ~/sage/src/sage/structure/parent.pyx:2587, in sage.structure.parent.Parent.get_action() 2585 action = self._get_action_(S, op, self_on_left) 2586 if action is None: -> 2587 action = self.discover_action(S, op, self_on_left, self_el, S_el) 2588 2589 if action is not None: File ~/sage/src/sage/structure/parent.pyx:2683, in sage.structure.parent.Parent.discover_action() 2681 from sage.structure.coerce_actions import IntegerMulAction 2682 try: -> 2683 return IntegerMulAction(S, self, not self_on_left, self_el) 2684 except TypeError: 2685 _record_exception() File ~/sage/src/sage/structure/coerce_actions.pyx:743, in sage.structure.coerce_actions.IntegerMulAction.__init__() 741 if m is None: 742 m = M.an_element() --> 743 test = m + (-m) # make sure addition and negation is allowed 744 super().__init__(Z, M, is_left, operator.mul) 745 File ~/sage/src/sage/rings/semirings/tropical_semiring.pyx:278, in sage.rings.semirings.tropical_semiring.TropicalSemiringElement.__neg__() 276 if self._val is None: 277 return self --> 278 raise ArithmeticError("cannot negate any non-infinite element") 279 280 cpdef _mul_(left, right) noexcept: ArithmeticError: cannot negate any non-infinite element sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: p(x+1)(T(0)) # -----------------------------------Error 3 of 4----------------------------------- --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[5], line 1 ----> 1 p(x+Integer(1))(T(Integer(0))) File ~/sage/src/sage/structure/parent.pyx:901, in sage.structure.parent.Parent.__call__() 899 if mor is not None: 900 if no_extra_args: --> 901 return mor._call_(x) 902 else: 903 return mor._call_with_args(x, args, kwds) File ~/sage/src/sage/structure/coerce_maps.pyx:292, in sage.structure.coerce_maps.NamedConvertMap._call_() 290 raise TypeError(f"cannot coerce {x} to {C}") 291 cdef Map m --> 292 cdef Element e = method(C) 293 if e is None: 294 raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x))) File ~/sage/src/sage/symbolic/expression.pyx:7721, in sage.symbolic.expression.Expression._polynomial_() 7719 else: 7720 return R([self]) -> 7721 return self.polynomial(None, ring=R) 7722 7723 def fraction(self, base_ring): File ~/sage/src/sage/symbolic/expression.pyx:7595, in sage.symbolic.expression.Expression.polynomial() 7593 """ 7594 from sage.symbolic.expression_conversions import polynomial -> 7595 return polynomial(se lf, base_ring=base_ring, ring=ring) 7596 7597 def laurent_polynomial(self, base_ring=None, ring=None): File ~/sage/src/sage/symbolic/expression_conversions.py:1089, in polynomial(ex, base_ring, ring) 1030 """ 1031 Return a polynomial from the symbolic expression ``ex``. 1032 (...) 1086 1.87813065119873*x^2 + 20.0855369231877 1087 """ 1088 converter = PolynomialConverter(ex, base_ring=base_ring, ring=ring) -> 1089 res = converter() 1090 return converter.ring(res) File ~/sage/src/sage/symbolic/expression_conversions.py:212, in Converter.__call__(self, ex) 210 div = self.get_fake_div(ex) 211 return self.arithmetic(div, div.operator()) --> 212 return self.arithmetic(ex, operator) 213 elif operator in relation_operators: 214 return self.relation(ex, operator) File ~/sage/src/sage/symbolic/expression_conversions.py:1026, in PolynomialConverter.arithmetic(self, ex, operator) 1024 operator = mul 1025 ops = [self(a) for a in ex.operands()] -> 1026 return reduce(operator, ops) File ~/sage/src/sage/structure/element.pyx:1221, in sage.structure.element.Element.__add__() 1219 # Left and right are Sage elements => use coercion model 1220 if BOTH_ARE_ELEMENT(cl): -> 1221 return coercion_model.bin_op(left, right, add) 1222 1223 cdef long value File ~/sage/src/sage/structure/coerce.pyx:1278, in sage.structure.coerce.CoercionModel.bin_op() 1276 # We should really include the underlying error. 1277 # This causes so much headache. -> 1278 raise bin_op_exception(op, x, y) 1279 1280 cpdef canonical_coercion(self, x, y) noexcept: TypeError: unsupported operand parent(s) for +: 'Univariate Polynomial Ring in x over Tropical semiring over Rational Field' and 'Tropical semiring over Rational Field' sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: sage: z = T(0) sage: p(x+T(1))(z) # -----------------------------------Error 4 of 4----------------------------------- --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[5], line 1 ----> 1 p(x+T(Integer(1)))(z) File ~/sage/src/sage/structure/element.pyx:1221, in sage.structure.element.Element.__add__() 1219 # Left and right are Sage elements => use coercion model 1220 if BOTH_ARE_ELEMENT(cl): -> 1221 return coercion_model.bin_op(left, right, add) 1222 1223 cdef long value File ~/sage/src/sage/structure/coerce.pyx:1278, in sage.structure.coerce.CoercionModel.bin_op() 1276 # We should really include the underlying error. 1277 # This causes so much headache. -> 1278 raise bin_op_exception(op, x, y) 1279 1280 cpdef canonical_coercion(self, x, y) noexcept: TypeError: unsupported operand parent(s) for +: 'Symbolic Ring' and 'Tropical semiring over Rational Field' sage: