Subspaces in Mathematica

2018-03-21 08:30:20

I'm working on a research project and I need to learn how to use Mathematica to calculate subspaces. Specifically I plan to solve the following operations and I would greatly appreciate if you could give me an example of how to solve it.

For example:

In the vector space $Ρ^n$, consider the sub space

$$S = \left\langle(1, -2,1,0, ..., 0), (0,1, -2,1,0, ..., 0) ... (0,0, ..., 1, -2,1)\right\rangle$$

Calculate equations defining $S$ for $n = 4, 8, 16, 20$.

Find generator subspaces of "magic" matrices of $2\times2$, $3\times3$ and $4\times4$ (a square matrix is called magic if the sums of the elements in each row, each column and in the diagonal are always the same)

Both questions ask to find bases for the kernels (null spaces) of matrices.

The first one asks for the kernel of $S(n)$ where, in Mathematica, $S(n)$ can be created as

s[n_Integer] /; n >= 3 :=

SparseArray[{Band[{1, 1}] -> -1, Band[{1, 2}] -> 2, Band[{1, 3}] -> -1}, {n - 2, n}];

For instance,

  • Both questions ask to find bases for the kernels (null spaces) of matrices.

    The first one asks for the kernel of $S(n)$ where, in Mathematica, $S(n)$ can be created as

    s[n_Integer] /; n >= 3 :=

    SparseArray[{Band[{1, 1}] -> -1, Band[{1, 2}] -> 2, Band[{1, 3}] -> -1}, {n - 2, n}];

    For instance,

    NullSpace[s[4]]

    returns

    {{-2, -1, 0, 1}, {3, 2, 1, 0}}

    This means that every linear combination $(s_1, s_2, s_3, s_4)$ of rows of $S(4)$ satisfies two linear equations: $-2s_1 - s_2 + s_4=0$ and $3s_1+2s_2+s_3=0$ and, conversely, that every 4-vector satisfying these two equations can be written as a linear combination of rows of $S(4)$.

    There are two aspects to the second question. The first is to recognize that the constant (to which all the sums are equal) should be considered as a variable, along with the $n^2$ entries in the magic square of order $n$. This casts the question as giving a set of $n + n + 2$ equations in $n^2+1$ coefficients. The "generator subspace" of the

    2018-03-21 09:31:32
  • A)

    basis[std_, n_] :=

    If[n < Length[std], "Invalid specs",

    With[{null = ConstantArray[0, n - Length[std]},

    Flatten /@ Permutations[Prepend[null, std]]]]

    eqn[n_ /; (IntegerQ[n] && NonNegative[n])] := Array[x^(# - 1) &, n]

    combine[std_, n_] := eqn[n].# & /@ basis[std, n]

    TableForm[Table[Row[{ToString[k] <> "->", combine[{1, -2, 1}, k]}],

    {k, {4, 8, 16, 20}}], TableDepth -> 1]

    Gives:

    (*

    4->{1-2 x+x^2,x-2 x^2+x^3}

    8->{1-2 x+x^2,x-2 x^2+x^3,x^2-2 x^3+x^4,x^3-2 x^4+x^5,x^4-2 x^5+x^6,x^5-2 x^6+x^7}

    16->{1-2 x+x^2,x-2 x^2+x^3,x^2-2 x^3+x^4,x^3-2 x^4+x^5,x^4-2 x^5+x^6,...}

    20->{1-2 x+x^2,x-2 x^2+x^3,x^2-2 x^3+x^4,x^3-2 x^4+x^5,x^4-2 x^5+x^6,...}

    *)

    B)

    I have never encountered the term "generator subspace" before. Do you simply want a function that generates magic matrices? By generator subspaces, do you mean the column space of the magic matrix?

    2018-03-21 10:10:43