Search code examples
maxima

How to extract the basis vectors from nullspace


Is there a way to extract the basis vectors from nullspace(A)? For example, when I ran

A : matrix([1,2,3,4], [2,2,4,4]);
nullspace(A);

I got

span(v1, v2)

where v1 and v2 are the transpose of [0, -4, 0, 2] and [2,2,-2,0], respectively.

What I want to do is to use v1 & v2 to create another variable, e.g.

B : matrix(v1, v2)

Is there a way to do this, so that I don't need to read the screen and then manually enter v1 & v2 to create matrix B? Thanks a lot!


Solution

  • addcol pastes together columns. Try this:

    foo : nullspace (A);
    B : apply (addcol, args (foo));
    

    args(foo) returns the list of columns from the span expression (what you have labeled v1 and v2 above).