ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 08 Sep 2010 04:32:40 -0500"Abstract" linear algebrahttps://ask.sagemath.org/question/7670/abstract-linear-algebra/This is more of a general question about whether we can do with Sage what we normally do as mathematicians on paper and in our minds. For example, if I do
V = VectorSpace(QQ,4)
W = VectorSpace(QQ,4)
V==W
I get: True. This is quite disturbing - while V and W are isomorphic they should not be identical. As I understand it, a vectorspace over QQ for Sage is just QQ^4, that's it. In other words, the Linear algebra package, while excellent, is not really about vector spaces but rather about arrays of numbers.
Any thoughts on this desire of mine to have a genuine "coordinate-free" approach?
Mon, 06 Sep 2010 18:28:29 -0500https://ask.sagemath.org/question/7670/abstract-linear-algebra/Answer by niles for <p>This is more of a general question about whether we can do with Sage what we normally do as mathematicians on paper and in our minds. For example, if I do </p>
<p>V = VectorSpace(QQ,4)</p>
<p>W = VectorSpace(QQ,4)</p>
<p>V==W</p>
<p>I get: True. This is quite disturbing - while V and W are isomorphic they should not be identical. As I understand it, a vectorspace over QQ for Sage is just QQ^4, that's it. In other words, the Linear algebra package, while excellent, is not really about vector spaces but rather about arrays of numbers. </p>
<p>Any thoughts on this desire of mine to have a genuine "coordinate-free" approach?</p>
https://ask.sagemath.org/question/7670/abstract-linear-algebra/?answer=11584#post-id-11584I like coordinate-free linear algebra, but your issue here may simply be that `==` is not the "is identical" operator. Consider the following examples:
<pre>
sage: 3 == Mod(3,7)
True
sage: 3 == Mod(3,5)
True
sage: Mod(3,5) == Mod(3,7)
False
sage: Q = PolynomialRing(QQ,'t')
sage: 3 == Q(3)
True
sage: 3 in Q
True
sage: R = PolynomialRing(RR,'w,v')
sage: 3 == R(3)
True
sage: Q(3) == R(3)
False
</pre>
Given this behavior, I don't find it particularly surprising that `V == W` returns `True` above!
Of course, `id(V) == id(W)` also returns `True`, which is a little more surprising (to me). And the [free module](http://www.sagemath.org/doc/reference/sage/modules/free_module.html) documentation includes the following note:
> Note: In Sage it is the case that there is only one dense and one sparse free ambient module of rank `n` over `R`.
So it seems it's not even _possible_ to make two separate copies of a free module with a given rank. That seems a little limiting, which is your original point, I guess :) Maybe it's more accurate to think of `VectorSpace` as short for "`VectorSpaceWithCanonicalBasis`".Tue, 07 Sep 2010 04:31:05 -0500https://ask.sagemath.org/question/7670/abstract-linear-algebra/?answer=11584#post-id-11584Comment by marco for <p>I like coordinate-free linear algebra, but your issue here may simply be that <code>==</code> is not the "is identical" operator. Consider the following examples:</p>
<pre>sage: 3 == Mod(3,7)
True
sage: 3 == Mod(3,5)
True
sage: Mod(3,5) == Mod(3,7)
False
sage: Q = PolynomialRing(QQ,'t')
sage: 3 == Q(3)
True
sage: 3 in Q
True
sage: R = PolynomialRing(RR,'w,v')
sage: 3 == R(3)
True
sage: Q(3) == R(3)
False
</pre>
<p>Given this behavior, I don't find it particularly surprising that <code>V == W</code> returns <code>True</code> above!</p>
<p>Of course, <code>id(V) == id(W)</code> also returns <code>True</code>, which is a little more surprising (to me). And the <a href="http://www.sagemath.org/doc/reference/sage/modules/free_module.html">free module</a> documentation includes the following note:</p>
<blockquote>
<p>Note: In Sage it is the case that there is only one dense and one sparse free ambient module of rank <code>n</code> over <code>R</code>.</p>
</blockquote>
<p>So it seems it's not even _possible_ to make two separate copies of a free module with a given rank. That seems a little limiting, which is your original point, I guess :) Maybe it's more accurate to think of <code>VectorSpace</code> as short for "<code>VectorSpaceWithCanonicalBasis</code>".</p>
https://ask.sagemath.org/question/7670/abstract-linear-algebra/?comment=22697#post-id-22697Thanks for the comments! Given that they went to the trouble of implementing categories, this seems particularly strange. But I think this "problem" is common to all CAS.There must be a reference out there which works out the fundamentals for a CAS with higher fidelity.Tue, 07 Sep 2010 05:41:48 -0500https://ask.sagemath.org/question/7670/abstract-linear-algebra/?comment=22697#post-id-22697Comment by William Stein for <p>I like coordinate-free linear algebra, but your issue here may simply be that <code>==</code> is not the "is identical" operator. Consider the following examples:</p>
<pre>sage: 3 == Mod(3,7)
True
sage: 3 == Mod(3,5)
True
sage: Mod(3,5) == Mod(3,7)
False
sage: Q = PolynomialRing(QQ,'t')
sage: 3 == Q(3)
True
sage: 3 in Q
True
sage: R = PolynomialRing(RR,'w,v')
sage: 3 == R(3)
True
sage: Q(3) == R(3)
False
</pre>
<p>Given this behavior, I don't find it particularly surprising that <code>V == W</code> returns <code>True</code> above!</p>
<p>Of course, <code>id(V) == id(W)</code> also returns <code>True</code>, which is a little more surprising (to me). And the <a href="http://www.sagemath.org/doc/reference/sage/modules/free_module.html">free module</a> documentation includes the following note:</p>
<blockquote>
<p>Note: In Sage it is the case that there is only one dense and one sparse free ambient module of rank <code>n</code> over <code>R</code>.</p>
</blockquote>
<p>So it seems it's not even _possible_ to make two separate copies of a free module with a given rank. That seems a little limiting, which is your original point, I guess :) Maybe it's more accurate to think of <code>VectorSpace</code> as short for "<code>VectorSpaceWithCanonicalBasis</code>".</p>
https://ask.sagemath.org/question/7670/abstract-linear-algebra/?comment=22693#post-id-22693This behavior of "VectorSpace" -- which is *just* shorthand for K^n -- is very much by design. It's the same as what Magma does. Also, all this " trouble of implementing categories" was done 4 years after VectorSpace was implemented. The combinatorics code maybe has other more general modules.Wed, 08 Sep 2010 04:32:40 -0500https://ask.sagemath.org/question/7670/abstract-linear-algebra/?comment=22693#post-id-22693