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.Tue, 21 Feb 2017 02:33:00 +0100n-th power of matriceshttps://ask.sagemath.org/question/35155/n-th-power-of-matrices/Is there any way to calculate the n-th power of a (upper unitriangular) matrix in Sage? Here n is an integer variable.
For example, if y=matrix([[1,0,0],[0,1,1],[0,0,1]]), then I want to obtain a formula in n for y^n. In this case this would be y^n=matrix([[1,0,0],[0,1,n],[0,0,1]]).
I tried the following:
sage: y=matrix([[1,0,0],[0,1,1],[0,0,1]]); var('n');
sage: y^n
This resulted in the error: "NotImplementedError: non-integral exponents not supported"
Adding
sage: assume(n, 'integer')
has no effect at all.irisSun, 16 Oct 2016 10:56:39 +0200https://ask.sagemath.org/question/35155/How to make a symbolic function of a matrix ?https://ask.sagemath.org/question/36681/how-to-make-a-symbolic-function-of-a-matrix/ Hi,
I'm beginning with Sage. I've got two matrix Qf and Xf defined by :
Qf = 1000000*matrix([[0,0],[0,1]]);
Xf = matrix([1],[1675]);
I would like to write a symbolic function "f" which would take a matrix X with 2 rows & 1 column.
X = var('X');
f(X) = ((X-Xf).transpose()*Qf*(X-Xf));
I easily wrote it with python non-symbolic function syntax, but i didn't find a way to make it symbolic. Because I'll need his gradient later (which is easy to calculate by hand, that I conceed ^^).
Maybe, it's related with SR matrix, no idea, i'm beginning with Sage and that's why I'm asking for help x)
Thank you in advance.
Babacool51Tue, 21 Feb 2017 02:33:00 +0100https://ask.sagemath.org/question/36681/Does right_kernel_matrix support assumptions over the symbolic ring?https://ask.sagemath.org/question/34385/does-right_kernel_matrix-support-assumptions-over-the-symbolic-ring/I'm trying to a basis for the kernel of a symbolic matrix. However, exactly quite what the kernel is depends on the assumptions that have been made. It seems that although other matrix functions (e.g. calculating the inverse) respect assumptions the kernel function doesn't. Here is an example:
var('x,y')
M = Matrix(SR, [[x, 0],[0,y]])
print(~M) # Gives expected inverse [[1/x, 0], [0,1/y]]
print(M.right_kernel_matrix()) # Gives [] as expected (if x, y != 0 then M is invertible so has trivial kernel)
assume(x == 0)
# print(~M) # Throws an error (ZeroDivisionError)
print(M.right_kernel_matrix()) # Still gives [], whereas the kernel now has basis [(1, 0)]
Am I missing something here? Is it possible to use this function with assumptions?exodusTue, 09 Aug 2016 16:51:57 +0200https://ask.sagemath.org/question/34385/Multiplying matrices with different parents?https://ask.sagemath.org/question/27196/multiplying-matrices-with-different-parents/I want to conjugate a symbolic matrix, Sigma, by a matrix, garbage, over Z/9Z.
If I define both matrices as symbolic matrices, I get the right answer. If I define garbage over Z/9Z, I get confusing answers. Can anyone explain my results?
Sigma=matrix(SR,2,[[1+3*A,3*B],[3*C,1+3*D]])
garbage=matrix(SR,2,[[2,1],[2,6]]);garbageinverse=matrix(SR,2,[[6,8],[7,2]])
expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
R=Integers(9)
garbage=matrix(R,2,[[2,1],[2,6]]);garbageinverse=matrix(R,2,[[6,8],[7,2]])
expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[ 36*A + 42*B + 18*C + 21*D + 19 48*A + 12*B + 24*C + 6*D + 18]
[36*A + 42*B + 108*C + 126*D + 54 48*A + 12*B + 144*C + 36*D + 28]
36*A + 42*B + 108*C + 126*D + 54
[ 6*B + 3*D + 1 3*A + 3*B + 6*C + 6*D]
[ 0*A + 0*D 3*A + 0*D + 1]
6*B + 0*D
AcantiWed, 24 Jun 2015 18:39:06 +0200https://ask.sagemath.org/question/27196/