0
votes

The second part of the output of the eigenvectors function in Maxima is a list of the eigenvectors which correspond to the eigenvalues of the first part.

E.g.:

[[[1,-1/4],[1,1]],[[[1,2/3]],[[1,-1]]]]

(1,2/3) is the eigenvector of eigenvalue 1, and (1,-1) is the eigenvector of eigenvalue (-1/4).

How can I turn these vectors into a matrix (in this case it would be equivalent to matrix([1,1],[2/3,-1])).

Thanks

2

2 Answers

0
votes
(%i1) display2d: false $
(%i2) r: [[[1,-1/4],[1,1]],[[[1,2/3]],[[1,-1]]]] $
(%i3) s: second(r) $
(%i4) s: map('first, s) $
(%i5) s: apply('maplist, cons("[", s)) $
(%i6) s: apply('matrix, s);
(%o6) matrix([1,1],[2/3,-1])
0
votes

Here's an attempt. Notice I've extracted the pieces via multiple assignment first, so that it's easy to remember what the pieces mean.

(%i1) foo : [[[1,-1/4],[1,1]],[[[1,2/3]],[[1,-1]]]] $

(%i2) [[vals, mults], vecs] : foo;
                         1                  2
(%o2)            [[[1, - -], [1, 1]], [[[1, -]], [[1, - 1]]]]
                         4                  3
(%i3) vals;
                                         1
(%o3)                              [1, - -]
                                         4
(%i4) mults;
(%o4)                               [1, 1]
(%i5) vecs;
                                  2
(%o5)                       [[[1, -]], [[1, - 1]]]
                                  3
(%i6) apply (append, vecs);
                                   2
(%o6)                         [[1, -], [1, - 1]]
                                   3
(%i7) apply (matrix, apply (append, vecs));
                                  [     2  ]
                                  [ 1   -  ]
(%o7)                             [     3  ]
                                  [        ]
                                  [ 1  - 1 ]
(%i8) transpose (%);
                                  [ 1   1  ]
                                  [        ]
(%o8)                             [ 2      ]
                                  [ -  - 1 ]
                                  [ 3      ]

Not sure if that will work when the number of eigenvectors is different from number of eigenvalues and other special cases. But I hope this gives you something to go on.