We only store power series and p-adics to finite precision, so it's
impossible to tell whether the mathematical objects underlying two elements
in Sage are actually equal.  In practice, the goal of a p-adic or power
series computation is to determine some result approximately, since that's
all that's possible.  In this context, the notion of equality implemented
in Sage is the right choice.  For example, suppose you want to do some long
computation and determine whether you get 1 at the end.  At the end of your
computation, you find the answer 1 + O(t^33).  I think it's more useful to
say that this is equal to 1 than that it's not.

I'm not sure what kind of equality you would imagine, but if we defined
equality by something like "equal absolute precision and equal value modulo
that absolute precision" then you no longer have additive and
multiplicative inverses.  For example, if x = 1 + O(3^18) then there is no
value of y so that x+y == 0.  That's pretty devastating for thinking about
algebraic operations.

If you want to be more careful with the precision of your equality testing
you can use the `is_equal_to` method.

sage: x = 1 + O(3^14)
sage: y = 1 + O(3^16)
sage: x.is_equal_to(y, absprec=10)
True
sage: x.is_equal_to(y, absprec=15)
PrecisionError (most recent call last):
...
PrecisionError: Elements not known to enough precision

Finally, I'll note that there a bunch of precision models in Sage for
p-adics (they all apply in a power series context as well but haven't been
implemented there because it's a lot of work).  The tutorial
<http://doc.sagemath.org/html/en/reference/padics/sage/rings/padics/tutorial.html>
is still missing some of the newer ones (floating point precision and the
two lattice precisions), but you can pick out the details from the reference
manual
<http://doc.sagemath.org/html/en/reference/padics/sage/rings/padics/factory.html>
if you're willing to wade through a bunch of text.
David

On Wed, Jan 15, 2020 at 3:07 AM Sebastian Oehms <seb.oe...@gmail.com> wrote:

> Dear all,
>
>
> obviously Sage does not distinguish between precisions of power series:
>
> sage: R.<t> = PowerSeriesRing(ZZ)
> sage: O(t).is_zero()
> True
> sage: O(t) == O(t**2)
> True
>
> Similarly for p-adics:
>
> sage: O(3).is_zero()
> True
> sage: O(3) == O(3^2)
> True
> sage:
>
> This seems to be explicitly intended:
>
>
>    def __nonzero__(self):
>         """
>         Return True if this power series is not equal to 0.
>
>         EXAMPLES::
>
>             sage: R.<q> = ZZ[[ ]]; R
>             Power Series Ring in q over Integer Ring
>             sage: f = 1 + 3*q + O(q^10)
>             sage: f.is_zero()
>             False
>             sage: (0 + O(q^2)).is_zero()
>             True
>             sage: R(0).is_zero()
>             True
>             sage: (0 + O(q^1000)).is_zero()
>             True
>         """
>         return not not self.polynomial()
>
> Why?
>
> --
> 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 sage-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/10981ee0-efea-4885-850c-7e4dcd0e4d32%40googlegroups.com
> <https://groups.google.com/d/msgid/sage-devel/10981ee0-efea-4885-850c-7e4dcd0e4d32%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAChs6_mMXUCSZ4tHRJnvH-PyVku64vpf0AEgvE1%3DnHAAqMBC4g%40mail.gmail.com.

Reply via email to