Transfer matrix method. Here are some illustrating slides: http://www.math.ucsd.edu/~gptesler/184a/slides/184a_ch10.3slides_14-handout.pdf http://www.uwyo.edu/moorhouse/slides/transfer.pdf