Matrices to Tables
I'm new to Sage, so this is probably a basic question.
I'm trying to use Sage to construct a time series, and turn the output into some form of table or matrix. (I'm trying to do this to learn Sage). The way I want to construct the time series is to use two matrices A1 and A2, and two seed vectors x0 and x1 to calculate xt=A1x(t-1)+A2x(t-2). It's easy to calculate, say x3, x4, x5 by hard coding each vector. And I can write a program that outputs the first k entries in the time series as a series of 1x2 matrices or row vectors. And, of course, I could highlight that output, copy and paste it into wordpad, and then use find and replace to turn it into a csv file.
Here's my code:
xt=x1 xt1=x0 for k in range(100): xtp1=A_1xt+A_2xt1 xk=xt xt=xtp1 xt1=xt xt.transpose()
Where x1 and x0 are two 1x2 matrices (really vectors) representing the first two states of the system, and A_1 and A_2 are 2x2 matrices that represent the linear equations that produce the next time step.
But that last step (copy and pasting into wordpad) is super inelegant. I'd like to be able create a table with the outputs. But the problem is that the outputs are 1xk matrices (or I can easily turn them into 1xk vectors), but the table command takes lists as inputs, and I can't figure out how to turn these 1xk matrices into 1xk lists, or to get the table to take a 1xk matrix as an input. I've tried googling ways to coerce matrices or vectors into lists, but I think my Sage vocabulary isn't developed enough to get the results I need.
Please provide a self-contained example: give values for
x0,x1,A_1,A_2
, to make it easier for people to help you. Also, format your code as such by selecting it and pressing the101010
button.