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.Sat, 22 Nov 2014 10:16:28 +0100Can I get coefficients of a vector with respect to given basis for a vector space.https://ask.sagemath.org/question/24926/can-i-get-coefficients-of-a-vector-with-respect-to-given-basis-for-a-vector-space/Hello.
I have a question.
For example,
1. make vector space `V` by a basis `B=[1+x,3*x,x^2]` over the field of rationals`Q`
2. `v=3*x^2+17*x+5` in V
3. `v=a*B[0]+b*B[1]+c*B[2]` for some `a,b,c` in `Q`
4. `[a,b,c]`=?
We easily know the solution of previous example.
In general, for given basis `B` and a vector `v`, how can I get the list of coefficients?
And is it possible to the case of matrix space (`B`: the basis consists of matrices) ?
Thanks. :)Thu, 20 Nov 2014 12:10:29 +0100https://ask.sagemath.org/question/24926/can-i-get-coefficients-of-a-vector-with-respect-to-given-basis-for-a-vector-space/Answer by fidbc for <p>Hello.</p>
<p>I have a question.</p>
<p>For example,</p>
<ol>
<li>make vector space <code>V</code> by a basis <code>B=[1+x,3*x,x^2]</code> over the field of rationals<code>Q</code></li>
<li><code>v=3*x^2+17*x+5</code> in V</li>
<li><code>v=a*B[0]+b*B[1]+c*B[2]</code> for some <code>a,b,c</code> in <code>Q</code></li>
<li><code>[a,b,c]</code>=?</li>
</ol>
<p>We easily know the solution of previous example. </p>
<p>In general, for given basis <code>B</code> and a vector <code>v</code>, how can I get the list of coefficients?</p>
<p>And is it possible to the case of matrix space (<code>B</code>: the basis consists of matrices) ?</p>
<p>Thanks. :)</p>
https://ask.sagemath.org/question/24926/can-i-get-coefficients-of-a-vector-with-respect-to-given-basis-for-a-vector-space/?answer=24933#post-id-24933 Hi,
If `V` is the vector space, then you can simply ask for the coordinate vector of `v` by using `V.coordinate_vector(v)`. If you wish to use a different basis, then you can construct the subspace `U` spanned by the new basis (see [this](http://ask.sagemath.org/question/10327/changing-basis-on-a-vector-space/) other question) and then use `U.coordinate_vector(v)`.
Hope this helps.Thu, 20 Nov 2014 18:26:55 +0100https://ask.sagemath.org/question/24926/can-i-get-coefficients-of-a-vector-with-respect-to-given-basis-for-a-vector-space/?answer=24933#post-id-24933Comment by Semin for <p>Hi,</p>
<p>If <code>V</code> is the vector space, then you can simply ask for the coordinate vector of <code>v</code> by using <code>V.coordinate_vector(v)</code>. If you wish to use a different basis, then you can construct the subspace <code>U</code> spanned by the new basis (see <a href="http://ask.sagemath.org/question/10327/changing-basis-on-a-vector-space/">this</a> other question) and then use <code>U.coordinate_vector(v)</code>.</p>
<p>Hope this helps.</p>
https://ask.sagemath.org/question/24926/can-i-get-coefficients-of-a-vector-with-respect-to-given-basis-for-a-vector-space/?comment=24938#post-id-24938Oh, I see. By using that command, I solved my problem. :) I made a function that converts a polynomial to a vector in the vector space `V`. And then make the subspace `U` with the basis consists in converted vectors. Then I have coordinate vectors as I wanted. :)Sat, 22 Nov 2014 10:16:28 +0100https://ask.sagemath.org/question/24926/can-i-get-coefficients-of-a-vector-with-respect-to-given-basis-for-a-vector-space/?comment=24938#post-id-24938