**First you need to calculate** `A^n`.

Let's write down first few powers of `A.`

`A=[[2, 1],[0, 2]]`, ` ` `A^2=[[4,4],[0,4]]`, `A^3=[[8,12],[0,8]]`, `A^4=[[16,32],[0,16]]`, `A^5=[[32,80],[0,32]]`

From this we conclude that `A^n=[[2^n,n2^(n-1)],[0,2^n]]` which can be proven by mathematical induction.

**Let's now calculate the sum.**

`a_(11)=2+4+8+16+cdots+2^n=2cdot(2^n-1)/(2-1)=2(2^n-1)`

`a_(11)` is sum of first `n` elements of geometric sequence which we calculate by formula

`S_n=a_1cdot(q^n-1)/(q-1)` ** (1)**

where `a_1` is first element of the sequence and `q` is quotient of geometric sequence.

It is easy to see that `a_(22)=a_(11)` and `a_(21)=0.`

Let's now calculate `a_(12)`.

`a_(12)=1cdot2^0+2cdot2^1+3cdot2^2+cdots+(n-1)2^(n-2)+n2^(n-1)`

`2a_(12)=1cdot2^1+2cdot2^2+3cdot2^3+cdots+(n-1)2^(n-1)+n2^n`

Now we substract `2a_(12)-a_(12)` but in such way that we substract first part of `2a_(12)` and second part of `a_(12)`, second part of `2a_(12)` and third part of `a_(12)` (i.e. `1cdot2^1-2cdot2^1=-2^1`, `2cdot2^2-3cdot2^2=-2^2` etc.).

`2a_(12)-a_(12)=-1-2-2^2-2^3-cdots-2^(n-1)+n2^n=-1cdot(2^n-1)/(2-1)+n2^n=`

`=1-2^n+n2^n`

Again, we have used formula (1) for sum of first `n` elements.

**So final sum is**:

`A+A^2+A^3+cdots+A^n=[[2(2^n-1),1-2^n+n2^n],[0,2(2^n-1)]]`

First, let's try to figure out what `A^n` is. We look for a pattern:

`A^1 = [[2,1],[0,2]]`

`A^2 = [[4,4],[0,4]]`

`A^3 = [[8,12],[0,8]]`

`A^4 = [[16,32],[0,16]]`

`A^5 = [[32,80],[0,32]]`

The "diagonal" entries are `2^n`

The lower left entry is always 0

The upper right entry follows the pattern:

`1*2^0`, `2*2^1`, `3*2^2`, `4*2^3`, `5*2^4`, ...

That is, `n2^(n-1)`

So

`A^n = [[2^n,n2^(n-1)],[0,2^n]]`

Sidenote: if you wanted to prove this rigorously, you would use something called induction. The crux of the proof would be the following:

`[[2,1],[0,2]] A^n =`

`[[2,1],[0,2]] [[2^n,n2^(n-1)],[0,2^n]] =`

`[[2*2^n,n2^(n-1)*2+2^n],[0,2*2^n]] = `

`[[2^(n+1),(n+1)2^n],[0,2^(n+1)]] = A^(n+1)`

Now, we notice the following:

`(I + A + A^2 + ... + A^n)(I-A) = I - A^(n+1)`

where `I = [[1,0],[0,1]]`

To simplify, we write `A + A^2 + ... + A^n = B`

So our equation becomes:

`(I+B)(I-A)=I-A^(n+1)`

We want to find B.

If these were numbers, we would just divide both sides by (I-A). With matrices, you can't do that: you have to multiply both sides by the inverse (if it exists). So, we want to find the inverse of I-A (if it exists). Then:

`I+B = (I-A^(n+1))(I-A)^(-1)`

`I-A = [[1,0],[0,1]]-[[2,1],[0,2]]=[[-1,-1],[0,-1]]`

To get the inverse of a 2x2 matrix, switch the diagonal entries, negate the off-diagonal entries, and divide by the determinant. Thus:

`(I-A)^(-1) = [[-1,1],[0,-1]]`

So:

`I+B = ( [[1,0],[0,1]] - [[2^(n+1),(n+1)2^n],[0,2^(n+1)]] ) [[-1,1],[0,-1]]`

`= [[-1,1],[0,-1]] - [[-2^(n+1),2^(n+1)-(n+1)2^n],[0,-2^(n+1)]] `

`= [[-1+2^(n+1),1-2^(n+1)+(n+1)2^n],[0,-1+2^(n+1)]]`

Finally, to get B, subtract I from both sides:

`B = [[-2+2^(n+1),1-2^(n+1)+(n+1)2^n],[0,-2+2^(n+1)]]`