Computing the n-th power of a matrix, where n is a symbolic variable, is possible.

Using that, you could solve your problem as follows.

```
sage: J = matrix([[1, 0, 0], [0, -1/2-1/2*I, 0], [0, 0, -1/2 + 1/2*I]])
sage: n = SR.var('n')
sage: J^n
[ 1 0 0]
[ 0 (-1/2*I - 1/2)^n 0]
[ 0 0 (1/2*I - 1/2)^n]
sage: J.parent()([lim(x, n=infinity) for x in (J^n).list()])
[1 0 0]
[0 0 0]
[0 0 0]
```

Edit: this is simpler and more readable:

```
sage: J = matrix([[1, 0, 0], [0, -1/2-1/2*I, 0], [0, 0, -1/2 + 1/2*I]])
sage: n = SR.var('n')
sage: (J^n).apply_map(lambda x: lim(x, n=oo))
[1 0 0]
[0 0 0]
[0 0 0]
```

You could then define a function and apply it to any matrix.

```
sage: def limit_of_power(m):
....: n = SR.var('n')
....: return (m^n).apply_map(lambda x: limit(x, n=oo))
....:
sage: limit_of_power(J)
[1 0 0]
[0 0 0]
[0 0 0]
```

Is this homework ?

Yes, in the past it was! Now I'm using it as an exercise to learn a bit of Sage

Thank you so much for your answers!

I've edited the question to focus on the limit of the diagonal matrix. In Mathematica there is a way to do this directly, but finally I've found a workaround in Sage:

Maybe it's not the most efficient way to do this, but this works with diagonal matrices... The difference is that one needs to execute component by component, also for a more general case (non diagonal matrices).

Related: