Ask Your Question
0

n-th power of matrices

asked 2016-10-16 03:56:39 -0500

iris gravatar image

updated 2016-10-16 09:29:00 -0500

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.

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2016-10-16 15:39:14 -0500

castor gravatar image

updated 2016-10-16 16:00:57 -0500

You can find an interactive Sage application here: http://shrek.unideb.hu/~tengely/Magya... the last part is "Mátrixok n-edik hatványának zárt alakja", it is in Hungarian, but the mathematics and Sage command will help I think. In case of your example this code will not work, the eigenvalue 1 has multiplicity larger than 1. To make it work the computation related to the eigenvectors should be modified. At the above page the matrix is given by matrix([[1,2,1],[6,-1,0],[-1,-2,-1]]) and after pushing the "Számolás" button you see the general form of the $n$th power of this matrix. If you have a diagonalizable matrix the above code should do the job.

edit flag offensive delete link more
0

answered 2016-10-16 07:29:37 -0500

tmonteil gravatar image

updated 2016-10-16 07:34:03 -0500

Unless i misunderstand you question, if M is your matrix and n is an integer, you can just do:

sage: M^n

or, if you prefer to be Python compatible:

sage: M**n
edit flag offensive delete link more

Comments

Thank you for answering. However, I think you misinterpreted my question. To be clear, in my question n is a variable (as stated), while the matrix I want to calculate the n-th power of is known. I reformulated my question.

iris gravatar imageiris ( 2016-10-16 09:27:01 -0500 )edit

I see. The name variable could be misleading, since it can stand for a Python name, a polynomial indeterminate or a symbol. Thanks for having made your question more precise.

tmonteil gravatar imagetmonteil ( 2016-10-16 12:00:21 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-10-16 03:56:39 -0500

Seen: 138 times

Last updated: Oct 16 '16