A discrete linear dynamical system

Our example from Thursday

Our example from Thursday was the following: we were trapped on a desert island in which we find a mysterious room. Under this room there are three huge electrical plates, and when current runs through these plates they each produce a magnetic force.  The charge running through the three plates at a given time is recorded by a vector in ^3: each coordinate of the vector gives the charge through the corresponding plate at the given time.  The strength of the charge in each plate is proportional to strength of the magnet it induces.  What makes this system special is that the the current running through the plates at time t+1 is given by applying the matrix

A = ({{29/30, 2/15, -1/15}, {-3/10, 7/5, 3/10}, {-11/15, 11/15, 49/30}}) ;

to the vector which records the current passing through each plate at time t (which we'll call vt).

We're interested in calculating vt for arbitrary time t, and in class we noticed that this vector is given by applying the tth power of the matrix A to v0, where v0 is the initial state of the system.  For a random v0, the vector

v_t = A^tv_0

is quite difficult to compute, though, becuase it requires multiplying the (possibly huge) matrix A by itself t times.  

Special cases where the problem is easy

For some special choices of v0, though, finding the vectors vt isn't so difficult.  Suppose, for example, we have

v0 = {{0}, {1}, {2}}

( {{0}, {1}, {2}} )

Then we compute

A . v0

( {{0}, {2}, {4}} )

so that A(v0)=2(v0).  This means that we have

v_t = A^tv_0 = 2^tv_0

If instead we had

v0 = {{1}, {1}, {0}}

( {{1}, {1}, {0}} )

we can see that

A . v0

( {{11/10}, {11/10}, {0}} )

This means that A(v0)=1.1(v0), so that

v_t = A^tv_0 = 1.1^tv_0

We also see that with

v0 = {{1}, {0}, {1}}

( {{1}, {0}, {1}} )

we have

A . v0

( {{9/10}, {0}, {9/10}} )

so that A(v0)=0.9(v0), and hence

v_t = A^tv_0 = (0.9)^tv_0

Our clever idea in general is to use the fact that the three nice vectors we've found are linearly independent, and hence can be used to write any vector in ^3.  Then we'll have

v_t = A^tv_0 = A^t (c_1w_1 + c_2w_2 + c_3w_3) = c_1A^tw_1 + c_2A^tw_2 + c_3A^tw_3 = c_12^tw_1 + c_2 (1.1)^tw_2 + c_3 (0.9)^tw_3

which is much easier to compute than finding the tth power of the matrix A.

Simplifying computations by using eigenvectors

Does our clever idea actually save us time?  Let's find out.  We'll give a random initial vector

v0 = {{1}, {2}, {3}}

( {{1}, {2}, {3}} )

Now we'll see how long it takes to compute the state of the system at time 100,000 the old fashioned way

AbsoluteTiming[MatrixPower[A, 100000] . v0][[1]]

33.0274912 Second

That took a long time!  Even a computer had a hard time finding this vector, and would have an even harder time finding, say, the state of the system at time 1,000,000.

How long does it take when we solve it the new way?  First we need to write our vector as a linear combination of the others.

AbsoluteTiming[RowReduce[({{0, 1, 1, 1}, {1, 1, 0, 2}, {2, 0, 1, 3}})]]

{0.2703888 Second, ( {{1, 0, 0, 4/3}, {0, 1, 0, 2/3}, {0, 0, 1, 1/3}} )}

You can see that it doesn't take Mathematica long to write the given random vector as a linear combination of the three vectors we calculated in the first part of the problem.

So our vector is

4/3 ({{0}, {1}, {2}}) + 2/3 ({{1}, {1}, {0}}) + 1/3 ({{1}, {0}, {1}})

( {{1}, {2}, {3}} )

Now let's compute the state at time 100000 the new way using eigenvector

AbsoluteTiming[(4/3) * 2^100000 ({{0}, {1}, {2}}) + (2/3) * (11/10)^100000 ({{1}, {1}, {0}}) + (1/3) * (9/10)^100000 ({{1}, {0}, {1}})][[1]]

1.3519440 Second

It didn't take Mathematica much thought at all to crank out this vector, especially in comparision to calculating in the previous manner!