Le dimanche 01 avril 2012 à 21:01 +0100, Tom Bachmann a écrit : > On 01.04.2012 20:26, Aaron Meurer wrote: > >> Besides, how can a and b know which they belong to? This would require > >> having several different versions of e.g. sqrt(6): one in QQ[sqrt(6)], > >> one in QQ[sqrt(2), sqrt(3)], one in RR, one in CC, ... IIUC, Sage does > >> exactly that, but it feels profoundly wrong. > > > > I agree with this. Doing it this way feels like just too much > > unnecessary work (for the user). I think it makes sense to just > > define sqrt(6) in one way, namely, as 6**(1/2), and let each ring or > > field figure out how it makes sense in itself (or doesn't). This > > feels natural because sqrt(6) is actually implemented as Pow(6, > > Rational(1, 2)). Maybe if you are treating QQ<sqrt(6)> as a vector > > space, you can internally convert sqrt(6) to something like [0, 1]. > > But the coercion rules should make it so that you never need to even > > care about that, unless you are specifically working with code that > > requires this implementation, or if you are in the coercion code. > > > > Actually, I don't really see what is wrong with having several > "versions" of sqrt(6). Clearly the one inside C and the one inside R > should know about each other / be the same. But what about the element x > of the quotient ring QQ[x]/(x^2 - 6)? Surely they should not, a priory, > be the same?
Your x is an equivalence class of polynomials, it's not sqrt(6). You can't say that x > 2 or that log(x) == log(6)/2. > > >> > >> It should clearly be the other way round: R.mul(a, b) should be defined as > >> a*b. > >> And since we'd like ring operations to be symbolic objects, we should > >> even have R.mul = Lambda((x, y), x*y). > > > > So supposing that we had QQ<sqrt(6)>, and we wanted to define a*b as > > [a1*b1 + 6*a2*b2, a1*b2 + a2*b1], where a = [a1, a2], b = [b1, b2], > > and a = [a1, a2] means that a = a1 + a2*sqrt(6). Would it make sense > > to make R.mul equal to Lambda((x, y), x.as_vector()*y.as_vector())? > > > > I have been thinking about this (sort of thing). I agree that for > multiplication, it seems most natural to put the operation into the > elements. But for example equality comparison seems most naturally be > implemented in the ring. Indeed when working with various quotient > rings, we (or rather I, I guess) would not really like to implement > polynomials over and over, but I would still like to be able to write > down an element of say QQ[x,y]/(xy) and conclude somehow that > x^2*y == 0. > X**2*Y isn't an element of QQ[X, Y]/(XY), because the elements of the quotient ring are sets of polynomials. On the other hand, the congruence class of X**2*Y mod XY is in QQ[X, Y]/(XY) and is equal to the class of 0. This statement can be written as X**2*Y % X*Y == 0, so there's no need to invent a dodgy concept of context-dependent equality. -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.