WorksheetTheory

Worksheet: powers of a square matrix

Published · by

Open PDF The PDF is in Romanian.

Summary

The worksheet shows five methods for the powers of a square matrix: induction, repeating powers, the binomial theorem, the Cayley–Hamilton relation and matrices with sin and cos. Each method has its steps and a worked example. Then come exercises on three levels, a group activity and problems with transition matrices.

Press “Check” next to an exercise. Your answers stay on this device.

The question of this worksheet: How do you compute $A^{2026}$, or even $A^n$, without multiplying the matrix by itself 2025 times?

Start from what you know

Four quick checks. If one of them gives you trouble, write it down: go back to it first.

  1. Compute $A^2=A\cdot A$ for $A=\begin{pmatrix}1&2\\3&4\end{pmatrix}$.

  2. Expand $(x+1)^4$ with the binomial theorem.

    What is $C_5^2$?

  3. Fill in: $\cos(a+b)=\ldots$ and $\sin(a+b)=\ldots$

    Compute $\cos\frac{2\pi}{3}$ and $\sin\frac{2\pi}{3}$.

  4. Find the remainder when 2026 is divided by 3, by 4 and by 6.

Theory in brief

For each method: when to use it, the steps (in the thick frame) and a worked example. At the end you will find the logical thread that helps you choose the method.

Definition

Let $A\in\mathcal{M}_p(\mathbb{C})$ be a square matrix. The powers of $A$ are defined by $A^1=A$ and $A^{n+1}=A^n\cdot A$, for $n\in\mathbb{N}^*$. By convention, $A^0=I_p$.

Remember

$A^m\cdot A^n=A^{m+n}$, $\quad (A^m)^n=A^{mn}$, $\quad (kA)^n=k^nA^n$ for any number $k$.

Careful! Matrix multiplication is not commutative. In general $(AB)^n\ne A^nB^n$ and $(A+B)^2=A^2+AB+BA+B^2$, not $A^2+2AB+B^2$.

1. Compute, guess, prove by induction

★ Method

The method of mathematical induction

  1. I compute $A^2$, $A^3$ (and $A^4$ if needed).
  2. I look at which entries stay the same and how the others change. I write the guessed form of $A^n$ as a statement $P(n)$.
  3. I check $P(1)$.
  4. I assume $P(k)$ is true and compute $A^{k+1}=A^k\cdot A$. I get $P(k+1)$.

Example 1 · Induction

Compute $A^n$ for $A=\begin{pmatrix}2&1\\0&1\end{pmatrix}$.

Step 1. $A^2=\begin{pmatrix}4&3\\0&1\end{pmatrix}$, $\ A^3=\begin{pmatrix}8&7\\0&1\end{pmatrix}$.

Step 2. The first entry is a power of 2 and the entry next to it is 1 less. I guess $P(n)\colon A^n=\begin{pmatrix}2^n&2^n-1\\0&1\end{pmatrix}$.

Step 3. For $n=1$ I get $\begin{pmatrix}2&1\\0&1\end{pmatrix}=A$ ✓.

Step 4. $A^{k+1}=\begin{pmatrix}2^k&2^k-1\\0&1\end{pmatrix}\begin{pmatrix}2&1\\0&1\end{pmatrix}=\begin{pmatrix}2^{k+1}&2^k+2^k-1\\0&1\end{pmatrix}=\begin{pmatrix}2^{k+1}&2^{k+1}-1\\0&1\end{pmatrix}$ ✓.

2. Repeating powers

Sometimes, after a few multiplications, a simple matrix appears: $I_p$, $-I_p$, $O_p$ or even $A$ times a number. Then the powers “repeat” and you no longer need induction for every exercise.

★ Method

The method of repeating powers

  1. I compute $A^2$, $A^3$, … until $I_p$, $-I_p$, $O_p$ or a multiple of $A$ appears.
  2. If $A^k=I_p$, I divide $n$ by $k$: $n=k\cdot q+r$, with $0\le r<k$.
  3. I write $A^n=\left(A^k\right)^q\cdot A^r=A^r$ (with $A^0=I_p$).

Remember

$A^k=I_p\ \Rightarrow\ A^n=A^r$, where $r$ is the remainder of $n$ divided by $k$.

$A^k=-I_p\ \Rightarrow\ A^{2k}=I_p$.

$B^k=O_p\ \Rightarrow\ B^n=O_p$ for every $n\ge k$ (a nilpotent matrix).

$A^2=kA\ \Rightarrow\ A^n=k^{n-1}A$ for every $n\ge 1$.

Example 2 · The powers repeat

Compute $A^{2026}$ for $A=\begin{pmatrix}0&-1\\1&-1\end{pmatrix}$.

$A^2=\begin{pmatrix}-1&1\\-1&0\end{pmatrix}$, $\ A^3=A^2\cdot A=\begin{pmatrix}1&0\\0&1\end{pmatrix}=I_2$.

$2026=3\cdot 675+1$, so $A^{2026}=\left(A^3\right)^{675}\cdot A=A$.

Example 3 · $A^2=kA$

For $A=\begin{pmatrix}1&2\\2&4\end{pmatrix}$: $\ A^2=\begin{pmatrix}5&10\\10&20\end{pmatrix}=5A$.

Then $A^3=A^2\cdot A=5A^2=5^2A$ and, by induction, $A^n=5^{n-1}A$.

3. The binomial theorem

The identity matrix commutes with every matrix: $I_p\cdot B=B\cdot I_p=B$. That is why for $A=aI_p+B$ you may use the binomial theorem. The method is fast when a power of $B$ is $O_p$: the sum stops after a few terms.

Remember

If $XY=YX$, then $(X+Y)^n=\sum_{k=0}^{n}C_n^k\,X^{n-k}Y^k$.

If $A=aI_p+B$ and $B^2=O_p$, then $A^n=a^nI_p+n\,a^{n-1}B$.

If $A=aI_p+B$ and $B^3=O_p$, then $A^n=a^nI_p+n\,a^{n-1}B+\frac{n(n-1)}{2}\,a^{n-2}B^2$.

★ Method

The binomial theorem method

  1. I write $A=aI_p+B$. Usually $a$ is the number repeated on the main diagonal.
  2. I compute $B^2$, $B^3$, … until I get $O_p$.
  3. I apply the binomial theorem. The terms that contain $B^k=O_p$ vanish.
  4. I add the remaining matrices and check the formula for $n=1$.

Example 4 · The binomial theorem

Compute $A^n$ for $A=\begin{pmatrix}3&1&0\\0&3&1\\0&0&3\end{pmatrix}$.

$A=3I_3+B$, with $B=\begin{pmatrix}0&1&0\\0&0&1\\0&0&0\end{pmatrix}$, $\ B^2=\begin{pmatrix}0&0&1\\0&0&0\\0&0&0\end{pmatrix}$, $\ B^3=O_3$.

$$A^n=3^nI_3+n\cdot 3^{n-1}B+\frac{n(n-1)}{2}\cdot 3^{n-2}B^2=\begin{pmatrix}3^n&n\cdot 3^{n-1}&\frac{n(n-1)}{2}\cdot 3^{n-2}\\0&3^n&n\cdot 3^{n-1}\\0&0&3^n\end{pmatrix}$$

Check: for $n=1$ I get $A$ itself ✓.

Careful

The binomial theorem works only for matrices that commute. For $X=\begin{pmatrix}1&0\\0&0\end{pmatrix}$ and $Y=\begin{pmatrix}0&1\\0&0\end{pmatrix}$ we have $XY\ne YX$. Check for yourself that $(X+Y)^2\ne X^2+2XY+Y^2$.

4. The Cayley–Hamilton relation (2×2 matrices)

Every matrix $A=\begin{pmatrix}a&b\\c&d\end{pmatrix}\in\mathcal{M}_2(\mathbb{C})$ satisfies the relation below. The number $a+d$ is the sum of the entries on the main diagonal (the trace of the matrix). The number $ad-bc$ is the product of the entries on the main diagonal minus the product of those on the other diagonal.

Remember

$$A^2-(a+d)\,A+(ad-bc)\,I_2=O_2$$

With $s=a+d$ and $p=ad-bc$: $\ A^2=s\,A-p\,I_2$. The proof is a direct computation: you do it in exercise 5.

From the relation, every power of $A$ can be written as $A^n=x_nA+y_nI_2$. Multiplying by $A$ and replacing $A^2$:

$$A^{n+1}=x_nA^2+y_nA=(s\,x_n+y_n)\,A-p\,x_n\,I_2$$

So $x_{n+1}=s\,x_n+y_n$, $y_{n+1}=-p\,x_n$, that is $x_{n+2}=s\,x_{n+1}-p\,x_n$: a linear recurrence of order 2, as in the worksheet on sequences given by recurrences. Its characteristic equation, $r^2-s\,r+p=0$, has the same coefficients as the Cayley–Hamilton relation.

★ Method

The Cayley–Hamilton method

  1. I compute $s=a+d$, $p=ad-bc$ and write $A^2=s\,A-p\,I_2$.
  2. I look for the easy cases. If $p=0$: $A^2=sA$, so $A^n=s^{n-1}A$ (method 2). If $s^2=4p$: $\left(A-\frac{s}{2}I_2\right)^2=O_2$ (method 3).
  3. Otherwise, I write $A^n=x_nA+y_nI_2$, with $x_1=1$, $x_2=s$ and $x_{n+2}=s\,x_{n+1}-p\,x_n$.
  4. I solve the recurrence, write $y_n=-p\,x_{n-1}$ and check the formula for $n=1$ and $n=2$.

Example 5 · Cayley–Hamilton

Compute $A^3$ and $A^n$ for $A=\begin{pmatrix}4&-2\\1&1\end{pmatrix}$.

Step 1. $s=4+1=5$, $p=4\cdot 1-(-2)\cdot 1=6$, so $A^2=5A-6I_2$. Then $A^3=5A^2-6A=5(5A-6I_2)-6A=19A-30I_2$.

Steps 2–3. $p\ne 0$ and $s^2\ne 4p$. I write $x_{n+2}=5x_{n+1}-6x_n$, $x_1=1$, $x_2=5$.

Step 4. $r^2-5r+6=0$, $r_1=2$, $r_2=3$, so $x_n=3^n-2^n$ and $y_n=-6x_{n-1}=3\cdot 2^n-2\cdot 3^n$.

$$A^n=(3^n-2^n)\,A+(3\cdot 2^n-2\cdot 3^n)\,I_2=\begin{pmatrix}2\cdot 3^n-2^n&2^{n+1}-2\cdot 3^n\\3^n-2^n&2^{n+1}-3^n\end{pmatrix}$$

Check: $x_3=27-8=19$ and $y_3=24-54=-30$, the same as in Step 1 ✓.

5. Matrices with sin and cos

Definition

For $t\in\mathbb{R}$ we write $R(t)=\begin{pmatrix}\cos t&-\sin t\\\sin t&\cos t\end{pmatrix}$. Multiplying by $R(t)$ rotates a point of the plane about the origin by the angle $t$ (a rotation matrix).

Remember

$R(t)\cdot R(u)=R(t+u)$: it follows from the formulas for $\cos(t+u)$ and $\sin(t+u)$.

$R(t)^n=R(nt)$ for every $n\in\mathbb{N}^*$ (by induction). In particular $R(\pi)=-I_2$ and $R(2\pi)=I_2$.

Matrices that reduce to $R(t)$. If $A=\begin{pmatrix}a&-b\\b&a\end{pmatrix}$, $(a,b)\ne(0,0)$, and $r=\sqrt{a^2+b^2}$, then $A=r\begin{pmatrix}\frac{a}{r}&-\frac{b}{r}\\\frac{b}{r}&\frac{a}{r}\end{pmatrix}=r\,R(t)$, with $\cos t=\frac{a}{r}$, $\sin t=\frac{b}{r}$. So $A^n=r^n\,R(nt)$.

It is the same idea as the trigonometric form of the complex number $a+bi=r(\cos t+i\,\sin t)$.

★ Method

The rotation matrix method

  1. I check the form: the same number $a$ on the main diagonal, $-b$ (top) and $b$ (bottom) on the other diagonal.
  2. I compute $r=\sqrt{a^2+b^2}$ and factor out $r$.
  3. I find $t$ with $\cos t=\frac{a}{r}$ and $\sin t=\frac{b}{r}$.
  4. I write $A^n=r^n\,R(nt)$ and reduce the angle $nt$ to an angle in $[0,2\pi)$.

Example 6 · A rotation matrix

Compute $A^6$ and $A^{2026}$ for $A=\begin{pmatrix}1&-\sqrt{3}\\\sqrt{3}&1\end{pmatrix}$.

$r=\sqrt{1+3}=2$, $\cos t=\frac{1}{2}$, $\sin t=\frac{\sqrt{3}}{2}$, so $t=\frac{\pi}{3}$ and $A=2R\left(\frac{\pi}{3}\right)$.

$A^n=2^n\begin{pmatrix}\cos\frac{n\pi}{3}&-\sin\frac{n\pi}{3}\\\sin\frac{n\pi}{3}&\cos\frac{n\pi}{3}\end{pmatrix}$, so $A^6=2^6R(2\pi)=64\,I_2$.

$2026=6\cdot 337+4$, so $A^{2026}=2^{2026}R\left(\frac{4\pi}{3}\right)=2^{2026}\begin{pmatrix}-\frac{1}{2}&\frac{\sqrt{3}}{2}\\-\frac{\sqrt{3}}{2}&-\frac{1}{2}\end{pmatrix}=2^{2025}\begin{pmatrix}-1&\sqrt{3}\\-\sqrt{3}&-1\end{pmatrix}$.

★ Most important

How do I choose the method? Always start with $A^2$: most of the time it shows you the way.

  1. I compute $A^2$ (maybe $A^3$). Do $I_p$, $-I_p$, $O_p$ or $kA$ appear? → repeating powers.
  2. Is the same number $a$ repeated on the main diagonal, and does $B=A-aI_p$ have $B^2=O_p$ or $B^3=O_p$? → the binomial theorem.
  3. Does the matrix have the form $\begin{pmatrix}a&-b\\b&a\end{pmatrix}$? → $A=r\,R(t)$ and $A^n=r^n\,R(nt)$.
  4. Another 2×2 matrix? → the Cayley–Hamilton relation.
  5. Do $A^2$, $A^3$ show a clear pattern? → I guess the form of $A^n$ and prove it by induction.

Exercises

Work in order. For each exercise, first write down which method you choose and why.

Basic level

  1. Let $A=\begin{pmatrix}a&b\\c&d\end{pmatrix}\in\mathcal{M}_2(\mathbb{C})$. Compute $A^2$ and $(a+d)A$, then show that $A^2-(a+d)A+(ad-bc)I_2=O_2$.

  2. Let $A=\begin{pmatrix}1&3\\0&1\end{pmatrix}$.

    a) Compute $A^2$ and $A^3$.

    b) Guess the form of $A^n$ and prove it by mathematical induction.

    c) Compute $A^{10}$.

  3. Let $A=\begin{pmatrix}2&0&0\\0&-1&0\\0&0&3\end{pmatrix}$ be a diagonal matrix.

    a) Compute $A^n$, $n\in\mathbb{N}^*$.

    b) Compute $A^5$.

  4. Let $A=\begin{pmatrix}0&1\\-1&0\end{pmatrix}$.

    a) Compute $A^2$ and show that $A^4=I_2$.

    b) Compute $A^{2026}$ and $A^{2027}$.

  5. Let $A=\begin{pmatrix}2&-2\\1&-1\end{pmatrix}$.

    a) Show that $A^2=A$.

    b) Compute $A^{2026}$ and the sum $A+A^2+\ldots+A^{10}$.

  6. Let $A=\begin{pmatrix}1&2\\3&6\end{pmatrix}$.

    a) Find the real number $k$ for which $A^2=kA$.

    b) Compute $A^n$, $n\in\mathbb{N}^*$, and then $A^3$.

  7. Let $B=\begin{pmatrix}0&1&2\\0&0&3\\0&0&0\end{pmatrix}$. Compute $B^2$ and $B^3$. What is $B^{2026}$?

  8. Let $A=\begin{pmatrix}2&1\\0&2\end{pmatrix}$.

    a) Write $A=2I_2+B$ and compute $B^2$.

    b) Compute $A^n$ with the binomial theorem.

    c) Compute $A^5$.

  9. Let $A=\begin{pmatrix}1&2\\3&4\end{pmatrix}$.

    a) Write the Cayley–Hamilton relation for $A$.

    b) Find the real numbers $x$ and $y$ for which $A^3=xA+yI_2$.

    c) Compute $A^3$.

  10. Let $A=\begin{pmatrix}\frac{1}{2}&-\frac{\sqrt{3}}{2}\\\frac{\sqrt{3}}{2}&\frac{1}{2}\end{pmatrix}$.

    a) Find $t\in[0,2\pi)$ for which $A=R(t)$.

    b) Compute $A^3$ and $A^6$.

    c) What is the smallest $n\in\mathbb{N}^*$ for which $A^n=I_2$?

  11. True or false? For each false statement, give a counterexample in $\mathcal{M}_2(\mathbb{R})$.

    a) If $A^2=O_2$, then $A=O_2$.

    b) $(A+I_2)^n=\sum_{k=0}^{n}C_n^k\,A^k$ for every $A\in\mathcal{M}_2(\mathbb{R})$ and $n\in\mathbb{N}^*$.

    c) $(AB)^2=A^2B^2$ for all $A,B\in\mathcal{M}_2(\mathbb{R})$.

    d) If $A^3=I_2$, then $A^{2027}=A^2$.

Intermediate level

  1. Let $A=\begin{pmatrix}1&1&1\\0&1&1\\0&0&1\end{pmatrix}$.

    a) Write $A=I_3+B$ and compute $B^2$ and $B^3$.

    b) Show that $A^n=\begin{pmatrix}1&n&\frac{n(n+1)}{2}\\0&1&n\\0&0&1\end{pmatrix}$ for every $n\in\mathbb{N}^*$.

    c) Compute $A^{10}$.

  2. Let $A=\begin{pmatrix}3&1\\-1&1\end{pmatrix}$.

    a) Write the Cayley–Hamilton relation for $A$ and show that $(A-2I_2)^2=O_2$.

    b) Compute $A^n$, $n\in\mathbb{N}^*$.

    c) Compute $A^4$ in two ways: with the formula from b) and as $A^2\cdot A^2$.

  3. Let $A=\begin{pmatrix}5&-6\\3&-4\end{pmatrix}$.

    a) Show that $A^2=A+2I_2$.

    b) Write $A^n=x_nA+y_nI_2$ and show that $x_{n+2}=x_{n+1}+2x_n$.

    c) Find $x_n$, $y_n$ and $A^n$.

    d) Compute $A^5$.

  4. Group work · One matrix, three paths. Let $A=\begin{pmatrix}1&-1\\1&1\end{pmatrix}$. The class splits into three groups.

    Group 1: compute $A^2$ and $A^4$ and use the repeating powers.

    Group 2: write the Cayley–Hamilton relation and express $A^3$ and $A^4$ in terms of $A$ and $I_2$.

    Group 3: write $A=\sqrt{2}\,R(t)$ and use $R(t)^n=R(nt)$.

    a) All groups: compute $A^8$.

    b) Show that $A^{2026}=2^m\begin{pmatrix}0&-1\\1&0\end{pmatrix}$ and find the natural number $m$.

    c) Compare your solutions: which path was the shortest? Which path would you choose for $A^{2027}$?

  5. Let $A=\begin{pmatrix}\sqrt{3}&1\\-1&\sqrt{3}\end{pmatrix}$.

    a) Find $t\in(-\pi,\pi]$ for which $A=2R(t)$. Watch the signs!

    b) Compute $A^6$ and $A^{12}$.

    c) What is the smallest $n\in\mathbb{N}^*$ for which $A^n=k\,I_2$, with $k$ a real number?

  6. Find the mistake. A student writes: “$A=\begin{pmatrix}2&1\\1&2\end{pmatrix}=2I_2+B$, with $B=\begin{pmatrix}0&1\\1&0\end{pmatrix}$, so $A^n=2^nI_2+n\cdot 2^{n-1}B$.”

    a) Check the student’s formula for $n=2$. Where is the mistake?

    b) Compute $B^2$ and redo the computation with the binomial theorem, grouping the terms with $B^k=I_2$ and those with $B^k=B$ separately. Hint: $3^n=(2+1)^n$ and $1=(2-1)^n$.

    c) Show that $A^n=\frac{3^n+1}{2}\,I_2+\frac{3^n-1}{2}\,B$ and compute $A^4$.

  7. Let $J=\begin{pmatrix}1&1&1\\1&1&1\\1&1&1\end{pmatrix}$.

    a) Show that $J^2=3J$ and deduce that $J^k=3^{k-1}J$ for $k\ge 1$.

    b) Using the binomial theorem, show that $(I_3+J)^n=I_3+\frac{4^n-1}{3}\,J$.

    c) Compute $\begin{pmatrix}2&1&1\\1&2&1\\1&1&2\end{pmatrix}^3$.

Advanced level

  1. For $x\in\mathbb{R}$ let $M(x)=\begin{pmatrix}1&x&\frac{x^2}{2}\\0&1&x\\0&0&1\end{pmatrix}$.

    a) Show that $M(x)\cdot M(y)=M(x+y)$ for all $x,y\in\mathbb{R}$.

    b) Deduce $\left(M(x)\right)^n$ and compute $\left(M(1)\right)^{10}$.

    c) Compute the product $M(1)\cdot M(2)\cdot\ldots\cdot M(10)$.

  2. The Fibonacci sequence is defined by $F_0=0$, $F_1=1$, $F_{n+1}=F_n+F_{n-1}$, $n\ge 1$. Let $A=\begin{pmatrix}1&1\\1&0\end{pmatrix}$.

    a) Prove by induction that $A^n=\begin{pmatrix}F_{n+1}&F_n\\F_n&F_{n-1}\end{pmatrix}$ for every $n\in\mathbb{N}^*$.

    b) Compute $A^{10}$.

    c) Using $A^{m+n}=A^m\cdot A^n$, show that $F_{m+n}=F_{m+1}F_n+F_mF_{n-1}$ for all $m,n\in\mathbb{N}^*$.

  3. Let $A\in\mathcal{M}_2(\mathbb{R})$ with $A^3=O_2$, and let $s$ and $p$ be the numbers in the Cayley–Hamilton relation $A^2=sA-pI_2$.

    a) Show that $A^3=(s^2-p)\,A-sp\,I_2$.

    b) Show that $A^2=O_2$. Hint: treat the case $A=k\,I_2$ separately.

  4. How many distinct matrices does the set $\{A^n\mid n\in\mathbb{N}^*\}$ have for each of the matrices below?

    a) $A=R\left(\frac{2\pi}{7}\right)$

    b) $A=\begin{pmatrix}0&-1\\1&-1\end{pmatrix}$ (from Example 2)

    c) $A=\begin{pmatrix}1&1\\0&1\end{pmatrix}$

  5. Make up your own. Work in pairs.

    a) Find a matrix $B\in\mathcal{M}_2(\mathbb{Z})$, $B\ne O_2$, with $B^2=O_2$.

    b) Use it to build a matrix $A=aI_2+B$ and write an exercise like exercise 12 for your deskmate. Solve it yourself too, then swap notebooks and compare your solutions.

Matrices in real situations

The situations are made up, but they resemble real ones. You turn the data of a table into a matrix and use its powers to predict what comes next.

  1. Bikes for rent. A company has 100 bikes and two stations: Centre (C) and Park (P). On Monday morning all the bikes are at C. Every day, of the bikes that are at C in the morning, 80% end up at C again in the evening and 20% at P. Of those at P, 30% end up at C and 70% stay at P. No bike is lost and no new bikes are added.

    end up at \ leave from C P
    C $0{,}8$ $0{,}3$
    P $0{,}2$ $0{,}7$

    a) Write the transition matrix $T$ from the table. What does the entry $0{,}3$ mean? What do you notice about the sum of the entries in each column?

    b) Let $X_n=\begin{pmatrix}c_n\\p_n\end{pmatrix}$ be the number of bikes at C and at P after $n$ days, $X_0=\begin{pmatrix}100\\0\end{pmatrix}$. Show that $X_{n+1}=T\,X_n$ and deduce that $X_n=T^n X_0$.

    c) Compute $X_1$, $X_2$ and $X_3$.

    d) Write the Cayley–Hamilton relation for $T$, find $T^n$ and show that $c_n=60+\frac{40}{2^n}$.

    e) What happens to the number of bikes at each station after very many days? How many bikes should there be at C and at P so that their number no longer changes from one day to the next?

  2. The ship in the game. In a computer game, a ship starts at the point $(1,0)$. Each time a key is pressed, the ship rotates about the origin by $30^\circ$, counterclockwise. After $n$ presses its coordinates are $\begin{pmatrix}x_n\\y_n\end{pmatrix}=R\left(\frac{\pi}{6}\right)^n\begin{pmatrix}1\\0\end{pmatrix}$.

    a) After how many presses does the ship first get back to its starting point?

    b) Where is the ship after 2026 presses?

    c) The programmer wants the ship to also move away from the origin at each press: its distance to the origin doubles. Which matrix $A$ must be used instead of $R\left(\frac{\pi}{6}\right)$?

Frequently asked questions

How do I compute the n-th power of a square matrix?

Start with A² and maybe A³. If Iₚ, −Iₚ, Oₚ or a multiple of A appears, the powers repeat. If A = aIₚ + B and a power of B equals Oₚ, use the binomial theorem. A matrix of the form (a −b; b a) is written as r·R(t). For other 2×2 matrices use the Cayley–Hamilton relation, and when you see a clear pattern, prove it by induction.

What does the Cayley–Hamilton relation say for a 2×2 matrix?

For A with entries a, b in the first row and c, d in the second, A² − (a + d)·A + (ad − bc)·I₂ = O₂. You check it by direct computation. From it, every power can be written as Aⁿ = xₙ·A + yₙ·I₂, and xₙ satisfies a linear recurrence of order 2.

When can I use the binomial theorem for matrices?

Only when the two matrices commute: XY = YX. The identity matrix commutes with every matrix, so for A = aIₚ + B the formula always works. The method is fast when B² or B³ is the zero matrix, because the sum stops after two or three terms.

How do I raise a matrix with sin and cos to a power?

For the rotation matrix R(t), with cos t and −sin t in the first row and sin t, cos t in the second, R(t)·R(u) = R(t + u), so R(t)ⁿ = R(nt). A matrix with a, −b in the first row and b, a in the second is r·R(t), with r = √(a² + b²), as in the trigonometric form of the number a + bi.