On Wednesday, January 22, 2020 at 2:07:18 PM UTC+1, Marc Mezzarobba wrote: > > [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? > ;-) >
This is a good example, too. Here, even comparison using the predefined default precision wouldn't help. As I said before: It's impossible to avoid such wrong answers. The question is how we can make that transparent to the user and that question is independent on what realization of comparison has more advantages. Let me say just this without thinking about the work and annoyance for users practice that would cause: The cleanest solution would be to print a warning the first time a user applies `==` or `!=` to elements of non-exact rings (once per session or once per instance of such a ring). In addition a second pair of comparison operators (using infix operator) should be supplied giving according results but without warning. These new operators should be used in the doctests. But comparison is only one part of the irritations. The original issue (printing `O(u) + O(t)` as `O(u)`) has another reason, which can be explained by a look at the behavior in Nemo. Nemo does comparison in the same way as we do: 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 But there seems to be a principle difference: Sage allows the coexistence of exact (prec = infinity) and non-exact (prec = integer) elements, while Nemo seems to do not. Thus, in Nemo you have: julia> R(0) 0+O(t^100) while in Sage: sage: R.<t> = PowerSeriesRing(ZZ, default_prec=100) sage: R.zero() 0 sage: R.zero().prec() +Infinity Accordingly: 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) but: sage: S.<u> = PowerSeriesRing(R) sage: O(u) + O(t) O(u^1) On the one hand, this coexistence is reasonable, since mathematically polynomials are special power series. But since there are principle differences between exact and non-exact rings in computer algebra, this is another source of irritations. -- 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/d9409ee4-af17-42f5-ad03-738ff0e59bc1%40googlegroups.com.