1 | initial version |
This was asked again in Ask Sage question 35658, and an initial implementation was proposed as an answer to that question, and included in SageMath at Sage Trac ticket 22523.
A bug was reported in Ask Sage question 41622 and a fix for this bug was provided as an answer to that question and is ready for inclusion in SageMath at Sage Trac ticket 25082.
This makes it possible to compute the matrix power in the question here.
sage: n = SR.var('n')
sage: y = matrix([[1, 0, 0], [0, 1, 1], [0, 0, 1]]); y
[1 0 0]
[0 1 1]
[0 0 1]
sage: z = y^n; z
[1 0 0]
[0 1 n]
[0 0 1]
Then one can substitute for particular values:
sage: z.subs({n: 5})
[1 0 0]
[0 1 5]
[0 0 1]
sage: y^5
[1 0 0]
[0 1 5]
[0 0 1]