ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 01 Mar 2015 00:27:40 +0100dividing vector(a,b) by sqrt(x) gives (a/x*sqrt(x),b/x*sqrt(x))https://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/ I can't seem to figure out why the behavior above is happening.
I have been trying to familiarize myself with Sage as I am both an IT person at my university and currently a Calc III student and it would seem to me to be helpful for both to know how this software works since many professors use it and I can use it to check work in my classes.
When I attempt to get the unit vector in the direction of <1,1> I divide the vector by its magnitude, and instead of the expected result of <1/sqrt(2), 1/sqrt(2)> I have been getting <1/2*sqrt(2), 1/2*sqrt(2)> and this happens the same way with a vector divided by the sqrt of anything. (i.e. <1,1> / sqrt(3) == <1/3*sqrt(3), 1/3*sqrt(3)>)
Is this a bug, or am I missing something?
EDIT - To clarify, I am dividing a vector by it's magnitude, which is a scalar number. vector{a,b} divded by c should yield vector{a/c, b/c}. This works fine for integers. but when doing so with the sqrt() function it produces odd results. So if c == sqrt(d) the answer is coming back as vector{a/(d*c), b/(d*c)} and I don't understand why the denominator is being multiplied by d.
RickySun, 01 Mar 2015 00:27:40 +0100https://ask.sagemath.org/question/25980/vector division?https://ask.sagemath.org/question/10451/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)]MarkSun, 18 Aug 2013 05:18:06 +0200https://ask.sagemath.org/question/10451/