# vector division?

given a vector in sage

sage: a,b=var('a,b')
sage: sv=vector(SR,[1,a,b^2])


then why is this a meaningful operation

sage: sv/sv
1


To my (utterly humble) understanding, I always thought, that if vector multiplication '*' is defined via the scalar product - as it seems to be in sage

sage: sv*sv
a^2 + b^4 + 1


then, division cannot be defined meaningfully?

[Just as a sideremark along that line: I have no problem with numpy's element wise array-arithmetic

In [1]: v=array([1.,2.,3.]) # vector
In [2]: e=array([1.,1.,1.]) # unity is a vector
In [3]: e*v == v # multiplication by unity
Out[4]: array([ True,  True,  True], dtype=bool)
In [5]: vi=v**(-1) # inverse is a vector
In [6]: e/v == vi # unity/vector == inverse
Out[7]: array([ True,  True,  True], dtype=bool)
In [8]: e == v*vi # vector * inverse == unity
Out[9]: array([ True,  True,  True], dtype=bool)


In my layman's world, this type of division makes perfect sense. (Moreover I'm curious why sage seems to not adopt this pythonic way of array arithmetic)]

edit retag close merge delete

Note that * is not only inner product, but also multiplication by a scalar. Indeed 2*sv returns the expected answer. I'd say that Sage strives to give an interface that is closer to the mathematical usage, rather than the "pythonic" way. Sometimes this can be surprising, as in sv/sv.

( 2013-08-18 01:35:15 -0500 )edit

Sort by » oldest newest most voted

Division of two vectors is only allowed if they are a scalar multiple of each other, and the result is the ratio of their length. If not, you get an error:

sage: vector(QQ, [1,2,3]) / vector(QQ, [2,4,6])
1/2
sage: vector(QQ, [1,2,3]) / vector(QQ, [1,1,1])
Traceback (most recent call last)
...
ArithmeticError: vector is not in free module


The ratio is in the same base ring as the vectors, so if you have vectors over QQ then the ratio is rational, if you have vectors over SR then the ratio is again an element of the symbolic ring.

more

Ok., this makes (some) sense. Still, would you mind educating me on if this is just syntactic candy, or rather something absolutely standard that I should find in my high school linear algebra textbooks.

( 2013-08-18 01:09:01 -0500 )edit

It is funny.

1/sv


...
TypeError: unsupported operand parent(s) for '/': 'Integer Ring' and
'Vector space of dimension 3 over Symbolic Ring'


The vector sv has a division operator, which makes sense if interpreted as scalar multiplication:

sv.__div__(2)

(1/2, 1/2*a, 1/2*b^2)


The expression sv/2 is element of a vector space:

(sv/2).parent()

Vector space of dimension 3 over Symbolic Ring


As far nothing to complain.

I don't know why, but the expression sv/sv is astonishingly an element of the Symbolic Ring:

(sv/sv).parent()

Symbolic Ring

more

this is because your vector sv belongs to the symbolic ring (try sv.parent()). It is coherent that the answer belongs to the ring or field of your module or vector space.

( 2013-08-26 04:45:48 -0500 )edit