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.Thu, 16 Jul 2020 00:20:50 +0200Checking what the span is for a vectorhttps://ask.sagemath.org/question/52485/checking-what-the-span-is-for-a-vector/Let's assume I have a vector called v1 and I have a matrix called Matrix.
Let us assume that the vector is in the span of the rows of Matrix. How would I know what the linear combination is? Here is what I do know. Let's assume this is a m by n matrix. I do know there is the span function. So
I can do something like make a list of vectors out of the Matrix. Say something like make an empty list ListofVectors=[].
i=0
while i< m:
ListofVectors.append(M[i])
i+=1
Now doing
v1 in span(ListofVectors)
will give me true assuming v1 is in the span. However, is there a function that tells me what the coefficients are for each term. For example, the vector v1=[3,2,1] for the ListofVectors being [1,1,1], [1,0,0], and [0,1,0] should give me coefficients 1,2,1 respectively as 1*[1,1,1] + 2*[1,0,0] + 1*[0,1,0] gives [3,2,1].
whatupmattThu, 16 Jul 2020 00:20:50 +0200https://ask.sagemath.org/question/52485/How to treat a vector space as a group?https://ask.sagemath.org/question/33990/how-to-treat-a-vector-space-as-a-group/
I need to use a module as a group, so that I can define a group algebra over this module.
Essentially, I want to take the group of 2-dimensional complex vector space and define a group algebra over this. I cannot find appropriate direction on the internet and sage gives me the ridiculous "False" as below.
sage: V=FreeModule(CC,2)
sage: V in Groups()
False
Nihar GargavaFri, 01 Jul 2016 19:27:43 +0200https://ask.sagemath.org/question/33990/simplify_rational gives different resultshttps://ask.sagemath.org/question/29753/simplify_rational-gives-different-results/ I am doing basic vector algebra calculation.
var('x0 y0 z0 a b c d')
B=vector([x0, y0, z0])
n=vector([a,b,c])
A=vector([0,0,d/c])
ab=B-A
proj=ab.dot_product(n)/n.norm()^2*n
However simplifying <code>proj</code> does not give me the expected results
proj.norm().simplify_rational()
Gives me:
sqrt((a^2*x0^2 + b^2*y0^2 + c^2*z0^2 - 2*a*d*x0 + d^2 + 2*(a*b*x0 -
b*d)*y0 + 2*(a*c*x0 + b*c*y0 - c*d)*z0)/(a^2 + b^2 + c^2))
However if I use the following addtional steps
tt=ab.dot_product(n)/n.norm()^2
(tt*n.norm()).simplify_rational()
The result is satisfactory:
(a*x0 + b*y0 + c*z0 - d)/sqrt(a^2 + b^2 + c^2)
In addition, if I ommit parenthesis the results become different again:
tt*n.norm().simplify_rational()
Results in
sqrt(a^2 + b^2 + c^2)*(a*x0 + b*y0 + c*(z0 - d/c))/(a*conjugate(a) +
b*conjugate(b) + c*conjugate(c))
And
(tt*n).norm().simplify_rational()
Results in
sqrt((a^2*x0^2 + b^2*y0^2 + c^2*z0^2 - 2*a*d*x0 + d^2 + 2*(a*b*x0 -
b*d)*y0 + 2*(a*c*x0 + b*c*y0 - c*d)*z0)/(a^2 + b^2 + c^2))
What are the exact difference? How do I ensure getting the desired outcome?neomaxSun, 04 Oct 2015 14:05:58 +0200https://ask.sagemath.org/question/29753/