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.Wed, 28 Apr 2021 13:31:54 +0200Issue with inversion of complex symbolic array initialized with numpyhttps://ask.sagemath.org/question/56850/issue-with-inversion-of-complex-symbolic-array-initialized-with-numpy/Hello!
I am trying to invert a symbolic matrix that is initialized with a combination of numpy arrays and I get an error. Below i present a simple code that gives the error.
import numpy as np
a = np.zeros((5,5) , dtype = 'complex')
np.fill_diagonal(a,1)
b = var('x')*a
c = matrix(b)
c.inverse()
Gives the error:
> ECL says: THROW: The catch
> MACSYMA-QUIT is undefined.
What I have noticed up until now is that the issue stems from the data type. When I try casting the numpy array to float before turning it into a matrix, it works. However, my actual code makes use of complex coefficients. I believe it might have to do with how the imaginary part is represented in SageMath in comparison to numpy. ( `j` vs `I` )
When I manually create the symbolic array with `I` for the imaginary part, the `.inverse()` has no issue.yorgos_sotWed, 28 Apr 2021 13:31:54 +0200https://ask.sagemath.org/question/56850/Keeping zeros after matrix multiplicationhttps://ask.sagemath.org/question/48925/keeping-zeros-after-matrix-multiplication/ Hello, Sage Community!
Suppose I do the following:
var('x y z')
u = vector([0, 1, 1])
v = vector([x, y, z])
u * v
The result is obviously `y+z`. I would like to keep the zeros after the multiplication, in order to have `0x+y+z` as my result. Is it possible?
Thanks in advance for your answers!dsejasSun, 01 Dec 2019 17:46:45 +0100https://ask.sagemath.org/question/48925/Solve symbolic matrix cellhttps://ask.sagemath.org/question/45841/solve-symbolic-matrix-cell/I'm trying to take a cell from a matrix and solve for a variable symbolically. When I run this, I get the error:
TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.
This is the code I am trying to execute:
var('a','b','c','x','y','z')
Rz = matrix([[cos(a),-sin(a),0,0],[sin(a),cos(a),0,0],[0,0,1,0],[0,0,0,1]])
Ry = matrix([[cos(b),0,sin(b),0],[0,1,0,0],[-sin(b),0,cos(b),0],[0,0,0,1]])
Rx = matrix([[1,0,0,0],[0,cos(c),-sin(c),0],[0,sin(c),cos(c),0],[0,0,0,1]])
P = matrix([[x],[y],[z],[1]])
Rzyxp = Rz * Ry * Rx * P
show(Rzyxp)
eqn2 = Rzyxp[2]
show(eqn2)
result1 = solve(eqn2==0, b)
show(result1)
Any help would be appreciatedMickey_PhippsTue, 19 Mar 2019 20:44:52 +0100https://ask.sagemath.org/question/45841/Quaternions Missing Important Functionality?https://ask.sagemath.org/question/34587/quaternions-missing-important-functionality/I use quaternions and Clifford algebras frequently for solving PDE boundary value problems as well as things like reflections, rotations etc. The underlying field for my quaternions is almost always either the complex numbers or the symbolic ring.
I am making an attempt to use them in Sage but I've run into a couple of obstacles that have given me pause. The absolute first things I looked for were,
1) scalar part or real part of the quaternion. Where is this function? I stumbled upon turning it into a list or vector but I presume that just taking the scalar part would be more efficient than dumping all the coefficients. For matrix representations it's often just the trace of the matrix. Correspondingly obtaining the vector part should be a standard function as well.
2) Quaternion automorphisms and anti-automorphisms? where are they? Yes we have conjugate which is both a method and an external function but what about the reversion and involution and the many other automorphisms? I don't expect to have to multiply by a bunch of unit vectors to get them for efficiency reasons. Also how do I distinguish between the quaternion conjugate and the complex conjugate of each of it's elements? This is a very important distinction that I would not know how to do without stripping out it's components and then remapping it.
3) Constructing a quaternion from coefficients. The only examples I've seen require explicit multiplications like
q = q0 + q1 * i + q2 * j + q3 * k . That doesn't seem efficient.
4) quaternions as elements of enclosing matrices and vectors. This would be very helpful since you could generate any Clifford algebra with this and it's often easier to analyze the components of said algebra that are isomorphic to Quaternions or Biquaternions in the complex case. Moreover I need to be able to do this for quaternions over the symbolic ring. It fails for me as this example from sage 7.3 shows:
<pre><code>
Q.<e1,e2,e3> = QuaternionAlgebra(SR, -1,-1)
var('x y z', domain='real')
q1 = x + x * I * e1
q2 = x - x * I * e1
v = vector([q1,q2])
</code></pre>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_36.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("US48ZTEsZTIsZTM+ID0gUXVhdGVybmlvbkFsZ2VicmEoU1IsIC0xLC0xKQp2YXIoJ3ggeSB6JywgZG9tYWluPSdyZWFsJykKcTEgPSB4ICsgeCAqIEkgKiBlMQpxMiA9IHggLSB4ICogSSAqIGUxCnYgPSB2ZWN0b3IoW3ExLHEyXSk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpQ0ibdW/___code___.py", line 7, in <module>
exec compile(u'v = vector([q1,q2]) File "", line 1, in <module>
File "sage/modules/free_module_element.pyx", line 510, in sage.modules.free_module_element.vector (/data/AppData/SageMath/src/build/cythonized/sage/modules/free_module_element.c:5811)
TypeError: unsupported operand type(s) for ** or pow(): 'QuaternionAlgebra_ab' and 'int'
5) quaternion rotations. Most libraries will generate the unit quaternion that rotates in 3D space and/or have a function that applies it efficiently.
There are probably a few other things like generating a canonical matrix representation for a full quaternion and so forth. I actually wonder if the default quaternion package is the right tool for a physicist or an engineer or someone who wants to play around with the so called geometric algebra of Hestenes. It seems the perogatives of the scientist vs the algebraist are very very different. How efficient is this library? What if I had to multiply millions of quaternions? I'm guessing I'd be better off mapping it to complex matrices and invoking blas.
While most of the functionality can be added on via a little python programming, I am concerned about efficiency and consistency. Moreover item 4 is a bit of a quandary since it involves overloading a bunch of arithmetic operators and some new python classes and so forth.
I'm hoping someone will tell me that it's all there, I just wasn't able to find it in the documentation or so forth. Thanks for any help in advance.doomFri, 26 Aug 2016 04:11:21 +0200https://ask.sagemath.org/question/34587/how can i define a matrix product like a summationhttps://ask.sagemath.org/question/38464/how-can-i-define-a-matrix-product-like-a-summation/ first, my mother tongue is not English but I try it, my problem is that if I define a symbolic matrix V such that,
var('V_11,V_12,V_13,V_21,V_22,V_23,V_31,V_32,V_33')
V = matrix(SR,3,3,[V_11,V_12,V_13,V_21,V_22,V_23,V_31,V_32,V_33])
and then I define
P = [V[a,k]*V[b,k]*V[a,j]*V[b,j] for k in [0,1,2] for j in [0,1,2]]
But if I evaluate, for example
P(a=0,b=1)
but the code is not work can someone help me?moiseszelenyThu, 03 Aug 2017 06:43:33 +0200https://ask.sagemath.org/question/38464/A^n, n=var(n')https://ask.sagemath.org/question/8280/an-nvarn/We have a matrix, for instance A = Matrix([[1,2],[3,4]])
How caculate A^n with n a variable (i.e symbolic calculus) and not n=50 or n = 100alreiffThu, 18 Aug 2011 22:51:31 +0200https://ask.sagemath.org/question/8280/Symbolic diagonalization, matrix differentiation and the wedge producthttps://ask.sagemath.org/question/36530/symbolic-diagonalization-matrix-differentiation-and-the-wedge-product/ May I ask whether symbolic entry-wise differentiation of matrices can be done using SageMath? I would like to conduct the following operations:
1.Diagonalize a complicated symbolic matrix.
2.Entry-wise differentiation.
3.The wedge product. I need to be able to take the n-th power of a matrix of 1-forms.
4.Integration (I will take the trace first before integrations so integrations will not be done on matrices. The result is likely to be completely crazy but I assume this can be done)
Please let me know whether this is possible. Thank you very much!MathCatFri, 10 Feb 2017 04:10:06 +0100https://ask.sagemath.org/question/36530/Printing (large) symbolic matriceshttps://ask.sagemath.org/question/33654/printing-large-symbolic-matrices/I am interested in calculating analytical Hessian for multivariable functions (up to several hundred variables).
My end game is solving this analytical Hessian against numerical ones.
I have successfully set up toy models for functions with a few variables like so:
k = var('k')
l = var('l')
h(x1, y1, z1, x2, y2, z2, x3, y3) = k * (sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z2)^2) - l)^2
H=f.diff(2)
print H(x1=0., y1=0., z1=0., x2=1., y2=1., z2=1.0)
However, trying it on a more complex function yields the following output when printing the symbolic matrix (I could include the function definition, but it is rather long ...):
27 x 27 dense matrix over Symbolic Ring
Are there intrinsic limitations to displaying such matrices, or am I just not calling the appropriate function for outputting it ?bertrand-caronFri, 03 Jun 2016 08:21:07 +0200https://ask.sagemath.org/question/33654/How do you Append a Symbolic Matrix?https://ask.sagemath.org/question/32406/how-do-you-append-a-symbolic-matrix/To All:
I am trying to make a function that will take a set of dynamics and a set of independent variables that can or cannot be within the dynamics equations to create a "frozen" state space matrix, A. I would like to tell you all now that I am mostly a FORTRAN coder and am in the process of trying to understand SageMath, which is why I am coding in a brute force method.
I previously checked to make sure that the derivative function was producing reasonable answers and created the matrices like this.
rmag = r[0]^2 + r[1]^2 + r[2]^2;
dyn = -mu*r/rmag^3; # spherical gravity assumption
ddyn_dx = dyn.derivative(r[0]);ddyn_dy = dyn.derivative(r[1]);ddyn_dz = dyn.derivative(r[2]);
pdyn_pr = (transpose(matrix([ddyn_dx,ddyn_dy,ddyn_dz])));
As you might have discovered, this is exceptionally tedious when the number of independent variables get larger.
Therefore, I desired to code something like this:
def FindDynMatrix(dynamics,xvect):
# Find the length of the vector defining the internal variables
# within dynamics are independent variables:
leng = len(xvect);
for j in range(leng):
vect = dynamics.derivative(xvect[j]);
if j == 0:
mat = vect;
else:
mat=matrix([mat,vect])
#mat = mat.append(vect) # didn't work
return mat
In "FindDynMatrix", symbolic vector that is dependent on a multitude of variables including those within the symbolic vector "xvect". The hope was to "black box" the production of the A matrix for a little controls tool that I am coding up.
However, I can not find a way to get this to work. Help would be appreciated.
PleaseNoCyrillicVariablesMon, 01 Feb 2016 00:56:36 +0100https://ask.sagemath.org/question/32406/Using matrix elements as argumentshttps://ask.sagemath.org/question/7774/using-matrix-elements-as-arguments/I have a rather easy question, or so it would seem. I have looked for an answer but was unable to find one anywhere so I'm asking it here.
I am making a very simple iterative algorithm for which the input as well as the output at the end of every iteration is a vector (or matrix for that matter). What I want to do is use these elements as arguments for several functions during each of the iteration. So for example
x=var('x')
y=var('y')
z=matrix(2,1,[ [1],[1] ]
f=x^2+y^3
H=f.hessian()
Then what I would like to do is say
H(z[0],z[1])
or
H(z)
But no matter what I try I can't seem to get it to work. Ideas?DisneySageFri, 26 Nov 2010 10:44:53 +0100https://ask.sagemath.org/question/7774/Symbolic matriceshttps://ask.sagemath.org/question/8074/symbolic-matrices/Hi,
is it possible to define totally symbolic matrices.
Something like
N,M = var('N,M')
a = matrix(SR, N, M)
b = matrix(SR, M, N)
c = a.dot(b)
So that c[i,j] = sum(a[i,k]*b[k,i],k,1,M) or do you really always need an non-symblic matrix size?
If you really always need a non-symblic matrix type, is it possible to define the symbolic variables automatically? Something like
a = matrix(SR, 2, 3)
print a[i,j]
output:
a_(i,j)
Thanks!
ManuelManuelsTue, 12 Apr 2011 08:01:26 +0200https://ask.sagemath.org/question/8074/symbolic 2x2 block matrix inversionhttps://ask.sagemath.org/question/10799/symbolic-2x2-block-matrix-inversion/Is it possible in SAGE to get the 2x2 block matrix inversion described in [Wikipedia](https://en.wikipedia.org/wiki/Block_matrix_pseudoinverse#Block_matrix_inversion)?
I looked at [this question](http://ask.sagemath.org/question/3245/determinant-of-block-matrices) about the determinant of block matrices, and at [this question](http://ask.sagemath.org/question/505/symbolic-matrices) about symbolic matrices, and tried the following code on the [cloud](http://www.sagenb.org/):
A = matrix(SR, 2, 2, 'a1 a2 a3 a4'.split(' '))
B = matrix(SR, 2, 2, 'b1 b2 b3 b4'.split(' '))
C = matrix(SR, 2, 2, 'c1 c2 c3 c4'.split(' '))
D = matrix(SR, 2, 2, 'd1 d2 d3 d4'.split(' '))
M = block_matrix(SR, 2, 2, [A, B, C, D])
Mi = M.inverse()
Mi.simplify_rational()
But it doesn't seem to be able to exactly reproduce the Wikipedia formula (it returns a horrible formula full of a1, a2, etc). Any idea?timflutreTue, 03 Dec 2013 17:05:46 +0100https://ask.sagemath.org/question/10799/Adjoint of symbolic matrix fails due to type conversionhttps://ask.sagemath.org/question/10366/adjoint-of-symbolic-matrix-fails-due-to-type-conversion/Trying the following code
var('x')
Matrix([[sqrt(x),x],[1,0]]).adjoint()
I get an error message
TypeError: no conversion of this rational to integer
This seems very strange to me. Computing the adjoint of any matrix should be possible, without requiring the elements to be rational, integral or anything else special. Over the symbolic ring in particular, it should always be possible to write the minors as expressions, perhaps without any evaluation or simplification in cases where doing more might cause trouble.
Surprisingly, computing the inverse works without issues. This is despite the fact that inversion requires division, and thus entails the danger of division by zero, where computing the adjoint does not. So one workaround might be multiplying the inverse by the determinant. But this will fail for some matrices where computing the adjoint should work. And it might also leave behind divisions within the elements, which might be difficult to get rid of without changing other radical changes to the form of the involved expressions. I just had a more complicated example where `simplify` left the division and `simplify_full` split square roots in a rather unreadable fashion.
Is there a valid explanation for the above behavior, or is this a bug?
Is there a better way to work around this problem?MvGFri, 19 Jul 2013 18:00:37 +0200https://ask.sagemath.org/question/10366/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/Problem with conjugate_transpose of a symbolic matrixhttps://ask.sagemath.org/question/10115/problem-with-conjugate_transpose-of-a-symbolic-matrix/ dAbar=diagAbar.subs(t=0);dAbar
[ 3.18953143618644*I*sech(x3) - 3.00000000000000 - 2.68953143618644*I
0 0]
[ 0
-3.18953143618644*I*sech(x3) - 3.00000000000000 + 2.68953143618644*I
0]
[ 0
0 -4]
TdiagAbar=dAbar.conjugate_transpose() + dAbar
Traceback (click to the left of this block for traceback)
...
AttributeError:
'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no
attribute 'sech'
I hope their is an easy answer. Thanks, nonlinearDionysusSat, 11 May 2013 23:46:41 +0200https://ask.sagemath.org/question/10115/Is it possible to find the exponential of a symbolic matrix using sage?https://ask.sagemath.org/question/8620/is-it-possible-to-find-the-exponential-of-a-symbolic-matrix-using-sage/I am searching for a function that is equivalent to mathematica's MatrixExp, that will calculate the exponential of a symbolic matrix. I don't want a term by term exponential but a something like expm() in scipy but for symbolic matrices.
Is it possible in sage?ShashankWed, 11 Jan 2012 16:50:15 +0100https://ask.sagemath.org/question/8620/A question on symbolic Matrices - unexpected Decimals in algebraic entryhttps://ask.sagemath.org/question/8942/a-question-on-symbolic-matrices-unexpected-decimals-in-algebraic-entry/Firstly, I'd just like to say that I am starting out with Sage adn Python at the moment, really impressed by the power of Sage and its potential! I am coming at this from an engineering and C++ background, and am currently trying to look at an engineering problem using some matrix linear algebra. I am setting up a from of stiffness matrix and am trying to extract the symbolic eigenvalues and eigenvectors from this. The stiffness matrix below is generated through a few different matrix multiplication operations, based on node and connectivity matrices. Despite trying to define these as being "SR" rings, I seem to end up with entries like (b + 1.0g + 1.0s) rather than the (b + g + s) I was expecting. I suspect this is due to me not understanding rings properly and how to apply them. I have tried the explanations in the Sage documentation, can anybody recommend some further reading or tutorials on this, because it does seem to be a vital topic in getting to grips with Sage?
I enclose my code below, in case anybody can spot a glaringly stupid thing that I've done...
many thanks,
Brian
N = matrix(QQ,[[1,0,-1,0],[0,1,0,-1]])
C = matrix(QQ,[[-1,0,1,0],[0,-1,0,1],[-1,1,0,0],[0,-1,1,0],[0,0,-1,1],[1,0,0,-1]])
D = C.transpose()
space = N.nrows()
M = N*D
M
II = identity_matrix(QQ,space)
b,s,g = var('b s g')
numMembers = M.ncols()
LVector = II
#loop through members to create LVector
for i in range(numMembers):
m1 = M.matrix_from_columns([i])
mt = m1.transpose()
mag = m1.norm()
Coeff = m1*mt/(mag^2)
size = m1.norm()
if i<2:
#for bars
L = -g*(II - Coeff) + b*Coeff
else:
L = g*(II - Coeff) + s*Coeff
L.factor()
if i == 0:
LVector = L
else:
LVector = LVector.block_sum(L)
print L.str()
print LVector.str()
Pre = D.tensor_product(II)
Post = C.tensor_product(II)
K = Pre*LVector
K = K*Post
Ks = K.change_ring(SR)
print Ks.str()
Eigen = K.eigenvectors_left()
print Eigen.str()BrianLoudonTue, 01 May 2012 07:22:55 +0200https://ask.sagemath.org/question/8942/Substituting for a matrix of variableshttps://ask.sagemath.org/question/8888/substituting-for-a-matrix-of-variables/I constructed a matrix of variables in the following way:
n = 3
R = PolynomialRing(RR,[['r','t'][cmp(int(i/n),i%n)]+'_'+str(1+int(i/n))+str(1+i%n) for i in range(n^2)])
S = matrix(R,3,R.gens())
show(S)
When i tried to substitute one of the variables with zero, it did not work.
n = 3
R = PolynomialRing(RR,[['r','t'][cmp(int(i/n),i%n)]+'_'+str(1+int(i/n))+str(1+i%n) for i in range(n^2)])
S = matrix(R,3,R.gens())
f = matrix([[S[i][j] for i in range(n)] for j in range(n)])
f({S[0][0]:0})
Interestingly though, the following snippet, decidedly the same to me, works with a similar syntax
xx = [var('alpha_%d'% (i+1)) for i in range(n)]
n = 3
R = PolynomialRing(RR,[['r','t'][cmp(int(i/n),i%n)]+'_'+str(1+int(i/n))+str(1+i%n) for i in range(n^2)])
S = matrix(R,3,R.gens())
def kron(i,j):
if i==j: return 1
else: return 0
def func(S,xx):
return [[(-1/2)*xx[i]*S[i][j]*kron(i,j) for i in range(n)]for j in range(n)]
f = matrix(func(S,xx))
diff_S = S*f.conjugate_transpose()*S - f
print diff_S({S[0][0]:0})
d3banjanSun, 15 Apr 2012 12:39:09 +0200https://ask.sagemath.org/question/8888/Function of symbols that is drawn from a matrix of symbols - does not work!https://ask.sagemath.org/question/8844/function-of-symbols-that-is-drawn-from-a-matrix-of-symbols-does-not-work/Please look at the first cell in [this worksheet](http://sagenb.org/home/pub/3619).
<h4>The Problem</h4>
Wanted to simplify the following symbolic calculation: If S be a matrix, nXn, of symbols - the matrix $A_{ab}=\sum_{c\ne{d}}S_{ac}S_{ad}S_{bd}S_{bc}$.
<h4>Construction of the matrix of symbols </h4>
n = 3
R = PolynomialRing(RR,[['r','t'][cmp(int(i/n),i%n)]+'_'+str(1+int(i/n))+str(1+i%n) for i in range(n^2)])
S = matrix(R,3,R.gens())
And this works, the matrix is constructed.
<h4> sanity Check </h4>
print [S[int(k/n)][k%n] for k in range(n^2)]
works perfectly.
<h4> Roadblock </h4>
However this construct does not work:
print [(S[i][int(k/n)]*S[i][k%n]*S[j][k%n]*S[j][int(k/n)])*(int(k/n)!=k%n)for k in range(n^2)]
and returns
Traceback (most recent call last):
File "", line 1, in <module>
File "/tmp/tmpQltfcX/___code___.py", line 10, in <module>
print [(S[i][int(k/n)]*S[i][k%n]*S[j][k%n]*S[j][int(k/n)])*(int(k/n)!=k%n)for k in range(n**_sage_const_2 )]
File "matrix0.pyx", line 924, in sage.matrix.matrix0.Matrix.__getitem__ (sage/matrix/matrix0.c:5540)
IndexError: matrix index out of range
Consequently the constructor for the matrix $A_{ab}$ doesnt work as well!
<h4> Check Again </h4>
print flatten([[[(i,int(k/n),k%n,j,1*(int(k/n)!=k%n))for k in range(n^2)]for i in range(n)]for j in range(n)])
returns a list containing 0, 1 and 2 s only. So the IndexError up there does not make sense either!
<h4>Edit: Addendum</h4>
n = 3
R = PolynomialRing(RR,[['r','t'][cmp(int(i/n),i%n)]+'_'+str(1+int(i/n))+str(1+i%n) for i in range(n^2)])
S = matrix(R,3,R.gens())
from operator import add
def Sh(i,j):
return reduce(add,[S[i][k//n]*S[i][k%n]*S[j][k%n]*S[j][k//n]*((k//n)!=k%n) for k in range(n^2)])
Shot = matrix(RR,n,n, Sh)
#print Shot
sage then returns the following error:
Traceback (most recent call last): #print flatten([[[(i,int(k/n),k%n,j,1*(int(k/n)!=k%n))for k in range(n^2)]for i in range(n)]for j in range(n)])
File "", line 1, in <module>
File "/tmp/tmpGXJyv5/___code___.py", line 12, in <module>
Shot = matrix(RR,n,n, Sh)
File "/sagenb/sage_install/sage-4.8-sage.math.washington.edu-x86_64-Linux/local/lib/python2.6/site-packages/sage/matrix/constructor.py", line 666, in matrix
return matrix_space.MatrixSpace(ring, nrows, ncols, sparse=sparse)(entries)
File "/sagenb/sage_install/sage-4.8-sage.math.washington.edu-x86_64-Linux/local/lib/python2.6/site-packages/sage/matrix/matrix_space.py", line 462, in __call__
return self.matrix(entries, copy=copy, coerce=coerce, rows=rows)
File "/sagenb/sage_install/sage-4.8-sage.math.washington.edu-x86_64-Linux/local/lib/python2.6/site-packages/sage/matrix/matrix_space.py", line 1266, in matrix
return self.__matrix_class(self, entries=x, copy=copy, coerce=coerce)
File "matrix_generic_dense.pyx", line 109, in sage.matrix.matrix_generic_dense.Matrix_generic_dense.__init__ (sage/matrix/matrix_generic_dense.c:2411)
File "parent.pyx", line 988, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7355)
File "polynomial_element.pyx", line 6316, in sage.rings.polynomial.polynomial_element.ConstantPolynomialSection._call_ (sage/rings/polynomial/polynomial_element.c:43471)
TypeError: not a constant polynomial
d3banjanTue, 10 Apr 2012 03:06:40 +0200https://ask.sagemath.org/question/8844/symbolic vector normhttps://ask.sagemath.org/question/8804/symbolic-vector-norm/I can't get Sage to produce the norm or even just compute `w[1]^2` in the code below. I keep getting a "not implemented" error. Have I made a simple mistake here, or is there a way around this? Thanks for the help. I haven't done much with matrix computations in Sage yet and am trying to learn my way around.
var('x,y')
a=matrix([[1,2],[-3,0]])
v=vector([x,y])
w=a*v.column()
w.norm()calc314Mon, 19 Mar 2012 16:25:19 +0100https://ask.sagemath.org/question/8804/Matrix of variables required, or is it there already?https://ask.sagemath.org/question/8234/matrix-of-variables-required-or-is-it-there-already/i am a python newbie. i needed a class that would support a fixed point search on a space of matrices. Is there any object that combines the methods of "sage.symbolic.expression" and "sage.matrix.matrix_generic_dense" ?d3banjanFri, 03 Feb 2012 04:57:11 +0100https://ask.sagemath.org/question/8234/Is there a way to block diagonalize a matrix?https://ask.sagemath.org/question/8503/is-there-a-way-to-block-diagonalize-a-matrix/I am trying to block diagonalize a four by four symbolic matrix in to two matrices of dimension two by two matrices. Is there a simple way to do it in sage?
ShashankMon, 28 Nov 2011 03:30:46 +0100https://ask.sagemath.org/question/8503/Symbolic linear algebrahttps://ask.sagemath.org/question/7715/symbolic-linear-algebra/Most of my research is in numerical methods/numerical analysis. I need to perform derivations using arbitrary matrices. Currently, when using sage, I have to declare all the elements of a symbolic matrix:
var('p00 p01 p02 p03 p10 p11 p12 p13 p20 p21 p22 p23 p30 p31 p32 p33')
Pmat=matrix([[p00,p01,p02,p03],[p10,p11,p12,p13],[p20,p21,p22,p23],[p30,p31,p32,p33]])
Clearly for large matrices this is prohibitively tedious. In Mathematica, I simply use:
pmat=Array[p,{4,4}]
I am then able to put constraints on the elements of p and solve for the values for the given method I am trying to derive. I prefer to use sage over Mathematica, so if someone can enlighten me how to accomplish this task in sage, I would appreciate it. tcfisherThu, 30 Sep 2010 10:22:36 +0200https://ask.sagemath.org/question/7715/