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?


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.

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

Reply via email to