In the last video, we saw how to
convert a system of 2nd order differential
equations to 1st order. In this video,
we're going to do the same thing with
difference equations, so that's 
discrete time evolution.
In other words, let's suppose we have
a system where the vector today is some
linear function of the vector yesterday -
sorry, a linear function of the vector
two days ago, plus another linear 
function of the vector yesterday.
The most famous example of this is
the Fibonacci sequence. We look at
numbers in a sequence where each number
is the sum of the previous two numbers.
We're gonna study the Fibonacci sequence
later in this video.
The technique we use for reducing this
to first order is very similar to the one
that we use for reducing differential
equations. We define a new vector,
call it y(n). y(n) is just x at time (n-1). 
It's just x yesterday.
That means that y yesterday was 
x the day before yesterday.
We can take our equations and write them
like this. y today is by definition,
x yesterday. And x today was 
A times x two days ago, well that's
y yesterday, plus b times x yesterday.
If you package y and x into a vector,
you get that y and x today are the
matrix 0, the identity, A, B,
times y and x yesterday.
This is the same kind of reduction that
we had for differential equations and
you may recognize the matrix M,
0, the identity, A, B.
The only difference is that before,
we had x followed by y.
For difference equations, we have 
y followed by x.
Okay, so how do we deal with that?
Well we diagonalize a matrix.
We diagonalize a matrix and once we 
diagonalize the big matrix, we have that
our vector at time m is given by the
eigenvectors of the matrix
times the eigenvalues to the nth power
times some arbitrary coefficients.
The vector d_j b_j is the eigenvector
of M, and we're letting d be the y part
and b be the x part. So last time
we had b_j d_j because we had x first
and y second. Now we have d b,
because we have y first and x second.
Just as before, we expand out what
each term means. The first row says
that b_j is lambda d_j.
The second is that A d + B b
is lambda b.
And if you then plug this into this
equation, you get that A_d + lambda b d
is lambda^2 d.
And put that all together - I'm sorry,
you multiply this whole thing through
by lambda and lambda d is just b.
So you get an equation for the b part.
The b part is what you're interested in
because ultimately, you're interested in
figuring out what x is doing.
And it satisfies this equation and 
in fact, that's the same equation that
we used when we were studying
differential equations.
And then our general solution,
if we only care about x, you see
if we care about y and x, we get
this big expansion. But if we ignore
the y part, we get that x is a linear
combination of powers of the
eigenvalues times the x part of
the eigenvectors.
So let's do the Fibonacci example.
The Fibonacci numbers,
the 0th Fibonacci number is 0.
The first Fibonacci number is 1,
and every successive Fibonacci number
is the sum of the previous two.
Our matrices are 1 x 1 matrices and
A is 1. There's A, and B is 1, there's B.
Actually this is A and this is B.
So we can make the matrix 0,
the identity A B, and by finding
the eigenvalues and eigenvectors of
this matrix, you can expand it.
The Fibonacci number problem where
you try to figure out this recursion
turns into the Fibonacci rapid problem
that was described by this matrix.
But we're gonna solve it not that way,
but via this equation here.
Here, A and B are just the number 1
and we're talking about 1 x 1 vectors.
So there is only one 1 x 1 vector 
up to scale, it's number 1.
So we get 1(b) + lambda(b) = 
lambda^2(b).
So lambda^2 is lambda+1 and the solutions
to those co radical equations are
lambdas (1+-√5)/2.
Our solution has to be x at time n 
is some constant times the eigenvector
which is just the number 1, 
times [(1+√5)/2]^n
plus another constant 
times [(1-√5)/2]^n
times the other eigenvector.
Now we plug in what happens at time 0
and at time 1.
See at time 0, you had x(0) was 0
and that c_1, something to the 0,
plus c_2, something to the 0
so that's c_1 + c_2.
At time 1, x(1) is 1. 
And that c_1, this to the first
plus that to the first.
If you go ahead and solve these 
equations, this says that c_1 and c_2
are negatives of each other.
You plug that into here and you do
a little algebra and you discover that
c_1 is 1/√5 and c_2 is -1/√5.
That gives you the value of the
nth Fibonacci number.
It's 1/√5 times this eigenvalue 
to the nth power minus this eigenvalue
to the nth power, and we're done.
We have solved the second order
recursion by using this magic formula.
Or we could have done it by finding
the eigenvalues and eigenvectors
of this matrix. Either way will work.
