dividing vector(a,b) by sqrt(x) gives (a/x*sqrt(x),b/x*sqrt(x))

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/(dc), b/(dc)} and I don't understand why the denominator is being multiplied by d.

edit retag close merge delete

Sort by » oldest newest most voted

Hello,

This is just a problem of display. The quantity 1 / sqrt(2) is just equal to 1 / 2 * sqrt(2). The latter is just another form of sqrt(2) / 2. And it is equal to the former if you divide both the numerator and the denominator by sqrt(2).

So it is not a bug but the way Sage displays the result.

Note that it also happens for numbers themselves:

sage: 1 / sqrt(2)
1/2*sqrt(2)


Vincent

more

Thank you very much for your response.

( 2015-02-28 18:44:13 -0600 )edit
1

Good on sage for not leaving radicals in the denominator.

( 2015-02-28 18:46:48 -0600 )edit

Great that you got it!

( 2015-02-28 18:51:51 -0600 )edit