>
> 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.
>

Sorry, that I was not clear enought about which precision I was referring 
to. I didn't mean the default precision of the ring, as you seem to do, but 
the individual precision of elements which can be set using the add_bigoh 
method (or global O function). In my examples the default precision has 
been:

sage: R
Power Series Ring in t over Integer Ring
sage: R.default_prec()
20


But the individual precisions of the elements where below that.

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.
>

My expectation is that two power series are considered to be equal if there 
polynomials agree, but also their individual precisions as long as one of 
them is below the default precision of the ring. Accordingly the `is_zero` 
method should not return True if the individual precision is below the 
default precision.

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

But this doesn't help for the following irritating answer (which was the 
original issue pointed out to me by Bill Hart):

sage: R.<t>=PowerSeriesRing(ZZ)
sage: S.<u>=PowerSeriesRing(R)
sage: 0 + O(t) + O(u)
O(u^1)


BTW: There is an inconsistency in the representation string which doesn't 
look very nice:


sage: O(t)
O(t^1)
sage: 1+O(t)
1 + O(t)

Best,
Sebastian


On Wednesday, January 15, 2020 at 4:09:29 PM UTC+1, David Roe wrote:
>
> 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....@gmail.com 
> <javascript:>> 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-...@googlegroups.com <javascript:>.
>> 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/d6ccee87-8c7f-4c47-8984-8310db95fb3e%40googlegroups.com.

Reply via email to