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/Matrix multiplication of sparse matrix with matrix over polynomial ringhttps://ask.sagemath.org/question/47196/matrix-multiplication-of-sparse-matrix-with-matrix-over-polynomial-ring/ Hi all,
I would like to know how to multiply the following matrices I have constructed in Sage. Here is my code for a toy example:
from scipy.sparse import csr_matrix
row = [0,0,1]
col = [0,1,1]
data = [1,-1,1]
A = csr_matrix((data,(row,col)),shape=(4,4))
R.<x,y> = PolynomialRing(QQ,2)
B = matrix(R,2,2,[1,x,1,y])
When I try to multiply the matrices using A.dot(B), I end up with the error: "No supported conversion for types: (dtype('int64'), dtype('O'))"
Is there a way I can multiply these matrices and yield an output that is a csr_matrix? (I suspect I would want to convert the entries of my A matrix to be the same data type, but I am unaware of how to do this)
Thank you for your time!
BarkWed, 17 Jul 2019 17:49:28 +0200https://ask.sagemath.org/question/47196/Characteristic polynomial wont be used in solvehttps://ask.sagemath.org/question/39746/characteristic-polynomial-wont-be-used-in-solve/ When I try to find roots in a characteristic polynomial it gives me errors:
sage: #Diagonalmatrix
....:
....:
....: A=matrix([[1,-1,2],
....: [-1,1,2],
....: [2,2,-2]])
....: var('x')
....: poly=A.characteristic_polynomial()
....: eq1=solve(poly==0,x)
....:
x
--------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-86-fee7a7de2ea1> in <module>()
7 var('x')
8 poly=A.characteristic_polynomial()
----> 9 eq1=solve(poly==Integer(0),x)
/usr/lib/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
816
817 if not isinstance(f, (list, tuple)):
--> 818 raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")
819
820 if len(f)==1:
TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.
sage:
What can I do in order to use the polynomial in an equation I wish to solve?PoetastropheThu, 23 Nov 2017 18:18:11 +0100https://ask.sagemath.org/question/39746/eigenvectors of complex matrixhttps://ask.sagemath.org/question/29989/eigenvectors-of-complex-matrix/Hi!
I would like to find the complex eigenvectors of this matrix:
A=matrix(CDF,[[2-i,0,i],[0,1+i,0],[i,0,2-i]]).
I have used the command A.eigenvectors_right() and I get the following eigenvectors (rounded off):
(-0.70711+9.4136e-17i , 0 , 0.70711), (0,1,0), (0.70711 , 0 , 0.70711)
In my checklist I should get the vectors: t1*(-1,0,1), t2*(0,1,0), t3*(1,0,1), where the t-values are complex factors.
How do I compute this kind of result?
Sincerly SimonismonWed, 14 Oct 2015 09:11:18 +0200https://ask.sagemath.org/question/29989/Symbolic matrices and "integrity" of their inversehttps://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/I have to solve the following problem:
Does a matrix $G\in GL(n,\mathbb{Z})$ exists such that
$$
G\times A\times G^{-1}=B
$$
being $A,B$ given matrices in $\mathbb{Q}$?
Doing everything by hand, I finally find myself with a bunch of symbolic matrices. Now I have to check if they can lay inside $GL(n,\mathbb{Z})$, i.e. if there are integer values for the variables in the matrix such that the matrix is integer, invertible and with integer inverse.
E.g.:
$$\left(\begin{array}{cc}x & 0 \\\\ 0 & y\end{array}\right)$$ does the trick only for $x=y=1$.
Is there a quick method within Sage to solve that last problem?
Thanks!JesustcMon, 17 Oct 2011 12:44:30 +0200https://ask.sagemath.org/question/8391/