--
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+...@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.
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.
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.
sage: R
Power Series Ring in t over Integer Ring
sage: R.default_prec()
20
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: R.<t>=PowerSeriesRing(ZZ)
sage: S.<u>=PowerSeriesRing(R)
sage: 0 + O(t) + O(u)
O(u^1)
sage: O(t)
O(t^1)
sage: 1+O(t)
1 + O(t)
To unsubscribe from this group and stop receiving emails from it, send an email to sage-...@googlegroups.com.
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.
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)
... This model has the advantage that (sqrt(1+t)^2 -1)/t == 1 returns true, as one would expect mathematically. (insisting equality up to the default precision would have to lead to false, because the arithmetic on the LHS leads to precision loss)
Indeed, but I think the actual bug there is: Power series rings over non-exact base rings don't work properly. This is a problem that you should expect: algebra algorithms normally designed to work with exact base rings will have problems with non-exact ones, and usually for the reason you see here: to work properly with power series over exact rings, you eliminate (exact) zeros, but the inexact zeros that you encounter in power series rings should probably be kept for precision tracking reasons (also the ones up to default precision!). But keeping them around indiscriminately would lead to impractical results very quickly. Special care is needed. You might try working with ZZ[['t','u']] instead.
Perhaps more importantly, I find the fact that series and p-adics (but
not intervals and balls) are doing that problematic for writing generic
code. Suppose that a is a symbolic expression, or an element of any
other parent where inequality is not decidable. Would you expect
a.is_zero() to return True whenever Sage is unable to prove that a is
nonzero? If not, what can code written for generic coefficient rings do
to work with both expressions and series?
Regarding power series in particular, the structure where
cos(sin(tan(t^2)) - tan(sin(t^2))) == 1 exists and makes perfect sense,
but it's the ring of polynomials mod t^20, not the ring of power series
with precision 20.
--
Marc
[re-posting a reply from a week ago that apparently did not go through
because gmane was moving]
Nils Bruin wrote:
> This model has the advantage that (sqrt(1+t)^2 -1)/t == 1 returns
> true, as one would expect mathematically.
Do you mean it has the advantage that cos(sin(tan(t^2)) -
tan(sin(t^2))) == 1 returns True, as one would expect mathematically?
;-)
julia> R, t = PowerSeriesRing(ZZ, 100, "t")
(Univariate power series ring in t over Integer Ring, t+O(t^101))
julia> O(t) == 0
true
julia> R(0)
0+O(t^100)
sage: R.<t> = PowerSeriesRing(ZZ, default_prec=100)
sage: R.zero()
0
sage: R.zero().prec()
+Infinity
julia> S, u = PowerSeriesRing(R, 20, "u")
(Univariate power series ring in u over Univariate power series ring in t over Integer Ring, u+O(u^21))
julia> O(u) + O(t)
0+O(t^100)+O(u^1)
sage: S.<u> = PowerSeriesRing(R)
sage: O(u) + O(t)
O(u^1)