On Sun, Apr 1, 2012 at 10:26 PM, Aaron Meurer <asmeu...@gmail.com> wrote:
> On Sun, Apr 1, 2012 at 12:08 PM, Ronan Lamy <ronan.l...@gmail.com> 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.

I think we absolutely must distinguish between concrete rings of
numbers and abstract rings.  I absolutely agree that having the user
explicitly specify which sqrt() to apply to a given number goes
against usual practise.  However, just as Tom says, I don't see
absolutely any problem with the fact that an *abstract* ring will have
to explicitly define sqrt(), should this definition make any sense.

>> 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())?

This would make sense *iff* R would have a large number of useful
properties (for example, if it were a vector space).  Attempting to
transform the arguments of R.mul to vectors imposes a lot of
unnecessary restrictions on R (like that it should be isomorphic to a
vector space).

I hope I understood your statement correctly.

Sergiu

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