On May 31, 11:14 am, Henryk Trappmann <[EMAIL PROTECTED]> wrote: > On May 31, 3:59 pm, "William Stein" <[EMAIL PROTECTED]> wrote: > > > However, there is a natural homomorphism from > > RR to the symbolic ring. > > Hm, if this is the precondition then the coercion of say RealField(52) > to RealField(2) is not valid, because it is no homomorphism at all. > For example let R2 = RealField(2), then > not R2(2.4+1.2)==R2(2.4)+R2(1.2) > > Wouldnt it then be more consistent coerce RealFields to higher > precision? There really a homomorphism exists. Then there always would > be a (desirable) difference between rounding and coercing. Rounding > has to be explicit while coercing is automatic.
Actually, there's no homomorphism either way; RR(R2(2)+R2(3)) != RR(R2(2)) + RR(R2(3)) Floating-point numbers are horrid, of course; trying to use them in a computer algebra system is just asking for trouble. But you really can't do without them, so you need to try to make the least bad choices. IMHO, giving a+b the precision of the less-precise operand is better than using the more-precise operand, because the latter has too much chance of confusing people who don't understand floating point. For instance, if 1.3+RealField(500)(pi) gave a 500-bit number, I'll bet a lot of people would assume that this number matched 13/10+pi to almost 500 bits. (Giving a 53-bit number is confusing too, but it's less dangerous, since you're less likely to believe you have the answer you wanted.) Of course, maybe there are other choices that are better than either of these. We could throw away RealField and always use RealIntervalField instead; but that's slower, has less special functions implemented, and has counterintuitive semantics for comparisons. We could do pseudo-interval arithmetic, and say that 1e6+R2(3) should be a 20-bit number, because we know about 20 bits of the answer; but to be consistent, we should do similar psuedo-interval arithmetic even if both operands are the same precision, and then RR becomes less useful for people who do understand how floating point works and want to take advantage of it. Carl --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---