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 01:51:51 +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.
Sun, 01 Mar 2015 00:27:40 +0100https://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/Answer by vdelecroix for <p>I can't seem to figure out why the behavior above is happening.</p>
<p>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.</p>
<p>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)>)</p>
<p>Is this a bug, or am I missing something?</p>
<p>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<em>c), b/(d</em>c)} and I don't understand why the denominator is being multiplied by d.</p>
https://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/?answer=25982#post-id-25982Hello,
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)
VincentSun, 01 Mar 2015 00:41:06 +0100https://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/?answer=25982#post-id-25982Comment by Ricky for <p>Hello,</p>
<p>This is just a problem of display. The quantity <strong>1 / sqrt(2)</strong> is just equal to <strong>1 / 2 * sqrt(2)</strong>. The latter is just another form of <strong>sqrt(2) / 2</strong>. And it is equal to the former if you divide both the numerator and the denominator by <strong>sqrt(2)</strong>.</p>
<p>So it is not a bug but the way Sage displays the result. </p>
<p>Note that it also happens for numbers themselves:</p>
<pre><code>sage: 1 / sqrt(2)
1/2*sqrt(2)
</code></pre>
<p>Vincent</p>
https://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/?comment=25987#post-id-25987Thank you very much for your response.Sun, 01 Mar 2015 01:44:13 +0100https://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/?comment=25987#post-id-25987Comment by Ricky for <p>Hello,</p>
<p>This is just a problem of display. The quantity <strong>1 / sqrt(2)</strong> is just equal to <strong>1 / 2 * sqrt(2)</strong>. The latter is just another form of <strong>sqrt(2) / 2</strong>. And it is equal to the former if you divide both the numerator and the denominator by <strong>sqrt(2)</strong>.</p>
<p>So it is not a bug but the way Sage displays the result. </p>
<p>Note that it also happens for numbers themselves:</p>
<pre><code>sage: 1 / sqrt(2)
1/2*sqrt(2)
</code></pre>
<p>Vincent</p>
https://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/?comment=25988#post-id-25988Good on sage for not leaving radicals in the denominator.Sun, 01 Mar 2015 01:46:48 +0100https://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/?comment=25988#post-id-25988Comment by vdelecroix for <p>Hello,</p>
<p>This is just a problem of display. The quantity <strong>1 / sqrt(2)</strong> is just equal to <strong>1 / 2 * sqrt(2)</strong>. The latter is just another form of <strong>sqrt(2) / 2</strong>. And it is equal to the former if you divide both the numerator and the denominator by <strong>sqrt(2)</strong>.</p>
<p>So it is not a bug but the way Sage displays the result. </p>
<p>Note that it also happens for numbers themselves:</p>
<pre><code>sage: 1 / sqrt(2)
1/2*sqrt(2)
</code></pre>
<p>Vincent</p>
https://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/?comment=25989#post-id-25989Great that you got it!Sun, 01 Mar 2015 01:51:51 +0100https://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/?comment=25989#post-id-25989