We have carriages of lengths 2 and 3.
Find a forumlar for the number of trains of length n that can be made from these carriages.
Note, this problem is very similar to the problem about trains described in lecture 11.
We need to work out what the relation is between tn and tn-1, tn-2 and tn-3.
It might help to draw more of the table:
| Length of train (n) | types of train | number of types | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | none | 0 | |||||||||
| 2 | [AA], [BB] | 2 | |||||||||
| 3 | [CCC] | 1 | |||||||||
| 4 |
| 4 | |||||||||
| 5 |
| 4 | |||||||||
| 6 |
| 9 |
To build a train of length n, we look at what it's head can be. There are three choices:
| [*****************train length n**************] |
| comes with the following heads: |
| [AA][*************train length n-2************] |
| [BB][*************train length n-2************] |
| [CCC][************train length n-3************] |
We want to find some relationship between the trains of lengh n and trains of shorter length.
There are tn-2trains of length n-2, so
So in total that means there are tn-2+tn-2+tn-3 trains of length tn.
So we have
The next thing to do is get a matrix equation. We can do this by getting equations for (tn,tn-1,tn-2) in terms of (tn-1,tn-2,tn-3). We get the following:
| tn | = | 0tn-1 | + | 2tn-2 | + | tn-3 |
| tn-1 | = | 1tn-1 | + | 0tn-2 | + | 0tn-3 |
| tn-2 | = | 0tn-1 | + | 1tn-2 | + | 0tn-3 |
Rewriting this as a matrix and vector equation, we have:
| / | tn | \ | / | 0 | 2 | 1 | \ | / | tn-1 | \ | |
| | | tn-1 | | | = | | | 1 | 0 | 0 | | | | | tn-2 | | |
| \ | tn-2 | / | \ | 0 | 1 | 0 | / | \ | tn-3 | / |
Next we'll introduce some short hand, xn and A: Let
| / | tn | \ | / | 0 | 2 | 1 | \ | ||||||
| xn | = | | | tn-1 | | | and | A | = | | | 1 | 0 | 0 | | | |
| \ | tn-2 | / | \ | 0 | 1 | 0 | / |
Then by sustituting n with n-1, we have
| / | tn-1 | \ | ||
| xn-1 | = | | | tn-2 | | |
| \ | tn-3 | / |
So the equation above in shorthand looks like
So xn=A2xn-2, since xn-1=Axn-2
We have x3=(t3,t2,t1), and from the table we made, we know this is (1,2,0).
Then
| x3=(1,2,0) |
| x4=Ax3 |
| x5=Ax4=A(Ax3)=A2x3 |
| x6=Ax5=A(A2x3)=A3x3 |
| x7=Ax6=A(A3x3)=A4x3 |
| x8=Ax7=A(A4x3)=A5x3 |
| x9=Ax8=A(A5x3)=A6x3 |
Generally, xn=An-3x3.
We can work with this, but we can also define x0, x1 and x2, by defining t0=1 t-1=0 and t-2=0, and we can check that the relationships with the tn also hold for these new tn, and then we get:
and since xn=An-3x3, by substitution,
To find a formula for xn in terms of n, we need to find how An changes x0. As usual, we do this via eigen values and eigen vectors:
1:Eigen Values.
2:Eigen Vectors:
We have to solve each of the systems with augemented matrices as below:
| / | 1 | 2 | 1 | | | 0 | \ |
| | | 1 | 1 | 0 | | | 0 | | |
| \ | 0 | 1 | 1 | | | 0 | / |
| / | -(1-root(5))/2 | 2 | 1 | | | 0 | \ |
| | | 1 | -(1-root(5))/2 | 0 | | | 0 | | |
| \ | 0 | 1 | -(1-root(5))/2 | | | 0 | / |
| / | -(1+root(5))/2 | 2 | 1 | | | 0 | \ |
| | | 1 | -(1+root(5))/2 | 0 | | | 0 | | |
| \ | 0 | 1 | -(1+root(5))/2 | | | 0 | / |
Do row reduction as usual, and find that
| For eigen value -1, the eigen vector is |
| |||||||||
| For eigen value T=(1-root(5))/2, the eigen vector is |
| |||||||||
| For eigen value R=(1+root(5))/2, the eigen vector is |
|
3: x0 in terms of eigen vectors:
The next thing to do is express the x0 in terms of the eigen vectors. We found that x0=(1,0,0), so we need to solve
| a |
| +b |
| +c |
| = |
|
Then
| An |
| = | (-1)na |
| +Tnb |
| +Rnc |
|
So since xn=(tn,tn-1,tn-2), we have
Need to finish this by finding a,b,c explicitly. We can use MatLab to get an answer, or we can work algebraically, and do the reduction by hand. Then we can use things like T2=T+1 and R2=R+1 (check this).
Which ever way you do it you'll get the same answer, though MatLab might have an error in approximating, but this will not be important.
Solving to find a,b,c:
| / | 1 | T2 | R2 | | | 1 | \ |
| | | -1 | T | R | | | 0 | | |
| \ | 1 | 1 | 1 | | | 0 | / |
When we row reduce to echelon, we end up with:
| / | 1 | 0 | 0 | | | 1/((1+T)(1+R)) | \ |
| | | 0 | 1 | 0 | | | 1/((1+T)(T-R)) | | |
| \ | 0 | 0 | 1 | | | 1/((1+R)(R-T)) | / |
This is equal to
| / | 1 | 0 | 0 | | | 1 | \ |
| | | 0 | 1 | 0 | | | (2-T)(?) | | |
| \ | 0 | 0 | 1 | | | (2-R)(?) | / |
If you use MatLab, you'll get
| / | 1 | 0 | 0 | | | 1 | \ |
| | | 0 | 1 | 0 | | | -1.1708 | | |
| \ | 0 | 0 | 1 | | | 0.1708 | / |
So
When we have the formular, we can quickly caluculate for example, the number of trains of length 35
Amazingly enough, when you type in the above, with n=35, MatLab will spit out an answer, and tell you that there are about 922746 trains of length 35 (There is a possible rounding error due to inaccuracies in values used for a,b,c,T,R; I've not yet worked out the order of the inacuracy, anyway, that's not important for this course.)
Please send comments, questions, suggestions, corrections, ideas, to me.
Welcome Home
Origami