Box manipulation
- To: mathgroup at smc.vnet.net
- Subject: [mg13514] Box manipulation
- From: Silvia Heubach <silvi at nospam.cinenet.net>
- Date: Fri, 31 Jul 1998 04:33:28 -0400
- Sender: owner-wri-mathgroup at wolfram.com
I have ventured into the deep parts of the internal Mathematica representations (at least for me). What I am trying to do is to compute a general solution to a system of difference equations in terms of the eigenvectors and eigenvalues. I have computed these terms and would now like to output them in nice mathematical form. I thought I had the solution until I came across some eigenvalues that were square roots and eigenvectors that were complex and resulted in sine and cosine terms. Below is my partial solution. The lists A and B are just as an example, but they reflect the structures I am dealing with. My code works for lists A and B, and the output gives you the format I would like to achieve. Lists A1 and B1 contain elements for which the code does not work. I tried unsucessfully commands like ToString or ToBoxes, but either its not the right thing or I used it at the wrong place. Any help is appreciated. Please email me directly at silvi at cinenet.net, as I have unsubscribed for summer from the list. Thanks in Advance Silvia Heubach **** This one works *************************************** A={1,2,3,4}; (*to stand for eigenvalues *) B={{1,2},{-3,2},{-1,0},{3,4}} ; (* to stand for eigenvectors*) Clear[str]; str={"x(k)="}; solterms=Table[{SubscriptBox["c",ToString[i]],"*",SuperscriptBox[A[[i]],"k"], "*","(",GridBox[Partition[B[[i]],1]],")","+"},{i,1,4}]; newstr=Drop[Flatten[AppendTo[str,solterms]],-1]; foo=RowBox[newstr]//DisplayForm; Print[foo] **** Here is where it breaks down - just different input, no change in code (except ajusting the names of the lists ************************** A1={1,Sqrt[2],3,4}; B1={{1,2},{Cos[2 k],0},{1,1},{Sin[-2 k],1}}; Clear[str]; str={"x(k)="}; solterms=Table[{SubscriptBox["c",ToString[i]],"*",SuperscriptBox[A1[[i]],"k"], "*","(",GridBox[Partition[B1[[i]],1]],")","+"},{i,1,4}]; newstr=Drop[Flatten[AppendTo[str,solterms]],-1]; foo=RowBox[newstr]//DisplayForm; Print[foo] **********