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, 25 Mar 2021 20:18:08 +0100Splitting a matrixhttps://ask.sagemath.org/question/56377/splitting-a-matrix/Dear SAGE community,
I am looking for a way that can help me split this matrix, A
A = matrix([[x], [x - 2*y]]), which is a linear combination of variables x, and y
into a Coefficient matrix, C = matrix([[1, 0], [1, -2]]) times the vector containing independent variables b = matrix([[x], [y]]).
Basically, A = C*b.
If there's a way to obtain the matrix C, would be really helpful.
-TIAApoorvThu, 25 Mar 2021 20:18:08 +0100https://ask.sagemath.org/question/56377/Checking 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/su2 matrix exponentiationhttps://ask.sagemath.org/question/43441/su2-matrix-exponentiation/Hi,
does anyone know if sage math is able to successfully calculate exp(G) where G belongs to su(2) ?
The sagemath commands are given below :
var('phi theta', domain='real')
u = vector([cos(phi)*sin(theta),sin(phi)*sin(theta),cos(theta)])
u.norm().simplify_trig()
sigma_x = matrix([[0,1],[1,0]])
sigma_y = matrix([[0,-i],[i,0]])
sigma_z = matrix([[1,0],[0,-1]])
sigma_x, sigma_y, sigma_z
var('t',domain='real')
G = -i*t*(sigma_x*u[0]+sigma_y*u[1]+sigma_z*u[2])
G.trace(), (G.det()/t**2).simplify_full(), G.is_hermitian()
exp(G)
exp(G) returns the following error code :
> TypeError: ECL says: Error executing
> code in Maxima: Unable to find the
> spectral representation
Thank you for helping.
EpiepimetheusWed, 22 Aug 2018 13:57:53 +0200https://ask.sagemath.org/question/43441/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/