 How to ignore a failed :g (global) command in a macro?
 Is there such thing as supreme board for international arbitrators?
 Two formulations of the continuity axiom in Expected Utility Theory
 Finding individual utility
 Mathematics for management
 D'Alembert's, Clairaut's and Euler's corrections to the Newton law of gravity
 Switch to *grep* buffer after running rgrep
 How to get autocompletion of Elisp function names?
 What Motivates the Dead?
 Logistics: How to move humanity onto a spaceship that is being built from planet Earth?
 Scripture to learn about manas, chitta, ahamkar and budhi in detail?
 Local to Production blank pages
 Multiple formulas for r squared eval metric for regression
 NLP features for Random Forest model
 Multiple keras models parallel  time efficient
 Spark for feature extraction from audio files
 Entropy loss from collapsing/merging two categories
 How to detect if human activity like walking, sitting, standing
 HTMLesque alternatives to Pug
 how to reduce file size in zip format to less than 10 mb
Subspaces in Mathematica
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 4vector 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
20180321 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>{12 x+x^2,x2 x^2+x^3}
8>{12 x+x^2,x2 x^2+x^3,x^22 x^3+x^4,x^32 x^4+x^5,x^42 x^5+x^6,x^52 x^6+x^7}
16>{12 x+x^2,x2 x^2+x^3,x^22 x^3+x^4,x^32 x^4+x^5,x^42 x^5+x^6,...}
20>{12 x+x^2,x2 x^2+x^3,x^22 x^3+x^4,x^32 x^4+x^5,x^42 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?
20180321 10:10:43