ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 28 Feb 2015 17:27:40 -0600dividing vector(a,b) by sqrt(x) gives (a/x*sqrt(x),b/x*sqrt(x))http://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.
RickySat, 28 Feb 2015 17:27:40 -0600http://ask.sagemath.org/question/25980/Vector.normalize() functionhttp://ask.sagemath.org/question/8296/vectornormalize-function/My question is something of a small complaint and need of an explination. Why is the normalize() function for vectors defined as it is, and not the "normal" way one would expect? This is somewhat confusing and frustrating especially if you need to have a normalized vector and what you get is a vector divided by the first non-zero element.rhoslugSat, 27 Aug 2011 19:29:23 -0500http://ask.sagemath.org/question/8296/Normalize vector to euclidean unit lengthhttp://ask.sagemath.org/question/9410/normalize-vector-to-euclidean-unit-length/I know I can compute a vector of unit length in a given direction using something like
v = some_vector_computation()
v = v/v.norm()
some_other_computation(v)
On the other hand, the most intuitive way to write this in a single line won't work:
some_other_computation(some_vector_computation().normalize())
This is because of the way `normalize` is defined, which is well documented and has been discussed in [this question](http://ask.sagemath.org/question/726/vectornormalize-function).
So I wonder, is there some other way to write the above in a single line? I'm not interested in solutions which call `some_vector_computation` twice, or have to name the vector, or use some lambda function, or similar hacks. I very much have a method in mind, but anything with similar complexibility and readability would be fine.
I know I could probably add my own method to the vector class at runtime, but modifying sage classes in this way doesn't exactly feel right. And I fear that using a non-standard method might make my code much harder to read, as others would expect being able to reproduce it, but won't be able to if they missed my custom method.
If there is no such method, do you agree that there should be, and that I should file a feature request on the Sage Trac?MvGWed, 10 Oct 2012 02:20:15 -0500http://ask.sagemath.org/question/9410/