# Ticket #9054: trac_9054_zero.patch

File trac_9054_zero.patch, 2.1 KB (added by saraedum, 10 years ago)

fixes the problems regarding zero.

• ## sage/rings/function_field/function_field_element.pyx

```exporting patch:
# HG changeset patch
# User Julian Rüth <julian.rueth@gmail.com>
# Date 1309281507 -7200
# Node ID 58c4d3f474221e7cdd8c5eab1d2fda05febcbdcf
# Parent  e515debf2b340e3d58cb352452503702b39e4385
Trac 9054: treat zero correctly

diff -r e515debf2b34 -r 58c4d3f47422 sage/rings/function_field/function_field_element.pyx```
 a """ FieldElement.__init__(self, parent) self._x = x self._x = x % self._parent.polynomial() def element(self): """ True sage: bool(L(0)) False sage: bool(L.coerce(L.polynomial())) False """ return not not self._x sage: K. = FunctionField(QQ); R. = K[]; L. = K.extension(y^2 - x*y + 4*x^3) sage: (2*Y + x/(1+x^3))  +  (3*Y + 5*x*Y)         # indirect doctest (5*x + 5)*Y + x/(x^3 + 1) sage: (Y^2 - x*Y + 4*x^3)==0                      # indirect doctest True """ cdef FunctionFieldElement res = self._new_c() res._x = self._x + (right)._x sage: K. = FunctionField(QQ); R. = K[]; L. = K.extension(y^2 - x*y + 4*x^3) sage: (2*Y + x/(1+x^3))  /  (2*Y + x/(1+x^3))       # indirect doctest 1 sage: 1 / (Y^2 - x*Y + 4*x^3)                       # indirect doctest Traceback (most recent call last): ... ZeroDivisionError: Cannot invert 0 """ return self * ~right sage: a*(2*Y + 1/x) 1 """ if self.is_zero(): raise ZeroDivisionError, "Cannot invert 0" P = self._parent return P(self._x.xgcd(P._polynomial)[1])