How to Compute Matrix Powers with Sage

  • MHB
  • Thread starter karush
  • Start date
In summary: Ill save it for laterIn summary, Sage is a free open source alternative to Mathematica and Maple. It is not well suited for solving the original problem.
  • #1
karush
Gold Member
MHB
3,269
5
$\textsf{Let:}$

$$ S=\left[\begin{array}{rrrrrr}
0& 1& 0& 0&0\\ 0& 0& 1& 0&0\\ 0& 0& 0&1&0\\0&0&0&0&0
\end{array}\right]$$

$Compute \, S^k k=2,...,6$

$\text{ok we are supposed to do this with SAGE}$

$\text{but not sure how $S^k$ is applied}$

i had this on another forum but just said it wasn't square
but i think S can be modified
 
Physics news on Phys.org
  • #2
karush said:
i had this on another forum but just said it wasn't square
but i think S can be modified

You are probably right, you can make it square, but this can be done in many ways and it is not clear to me which one to choose.
Does this matrix come from some application problem and could you deduce from there what modification would be most appropriate?
 
  • #3
The "other Forum" had a simple question that never got answered as far as I know.

What the (Swearing) is "SAGE?"

-Dan
 
  • #4
topsquark said:
What the (Swearing) is "SAGE?"
In the UK, it is the leading supplier of accounting software packages for small businesses, https://uk.sageone.com/accounts/.

I would not recommend it as a platform for linear algebra. (Fubar)
 
  • #5
Sage is a combination of various symbolic and numerical packages under open source licenses.
I never used it myself, although I did use some of its components.

I don't think this matters too much for the original question.
 
Last edited:
  • #6
The original post specifically said that this problem was to be solved "using SAGE". That is why it is "important" here.

Karush, I was the one who told you that we cannot find powers of that matrix because it is not square. I imagine there are many ways S can be "modified" to be square but then you no longer have "S" and are not answering the question asked! It may be that you mis-copied the problem. Please check that.
 
  • #7
Ok. I was curious now.
I've heard about SageMath before as a free open source alternative to Mathematica and Maple, which are both expensive.
... so I installed it, and tried it out...

Since we need a square matrix for S, I've made it a 4x4 matrix, which seems reasonable, because that makes it a standard nilpotent matrix.
Executing it in sage gives us:
Code:
sage: S=Matrix([[0,1,0,0],[0,0,1,0],[0,0,0,1],[0,0,0,0]])
sage: for k in range(5):
...:     S^(k+2)
...:     

[0 0 1 0]
[0 0 0 1]
[0 0 0 0]
[0 0 0 0]

[0 0 0 1]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]

[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]

[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]

[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]

And if I try it with the matrix in the OP, we get:
Code:
sage: S=Matrix([[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0],[0,0,0,0,0]])
sage: for k in range(5):
...:     S^(k+2)
...:     
---------------------------------------------------------------------------
ArithmeticError                           Traceback (most recent call last)
<ipython-input-38-5b09aa8b46ef> in <module>()
      1 for k in range(Integer(5)):
----> 2     S**(k+Integer(2))
      3 

sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense.__pow__ (/usr/lib/sagemath//src/build/cythonized/sage/matrix/matrix_integer_dense.c:11582)()

ArithmeticError: self must be a square matrix
 
  • #8
yeah the op was supposed be a 5x5

I never tried mathamatica or the other exotic programs but sage looks good to me

I have some more probs to post
 

FAQ: How to Compute Matrix Powers with Sage

What is the formula for computing S^k?

The formula for computing S^k is S^k = S x S x ... x S (k times), where S represents a number or variable.

Can S be a negative number when computing S^k?

Yes, S can be a negative number when computing S^k. The result will depend on the value of k. For example, if k is an even number, the result will be positive, but if k is an odd number, the result will be negative.

How does increasing k affect the value of S^k?

Increasing k will result in a higher value of S^k. This is because the formula for computing S^k involves multiplying S by itself k times, therefore, as k increases, the number of times S is multiplied also increases.

Can S^k be written in a different form?

Yes, S^k can be written in a different form using exponent rules. For example, S^k can be written as e^(klnS) or S^(k/2) can be written as √(S^k).

How is computing S^k related to exponential functions?

Computing S^k is directly related to exponential functions, as it is a way of representing repeated multiplication in exponential form. S^k can also be written as S^k = e^(klnS), which is the general form of an exponential function.

Similar threads

Replies
4
Views
2K
Replies
7
Views
1K
Replies
19
Views
2K
Replies
8
Views
2K
Replies
1
Views
1K
Replies
5
Views
1K
Replies
2
Views
859
Replies
3
Views
1K
Back
Top