# Finding minimum sub-algebra that contains a set

Hello, I'm trying to understand step 3 in the algorithm 1 provided in the paper "Algebraic Reduction of Hidden Markov Models" by Tommaso Grigoletto and Francesco Ticozzi.

It requires me to compute alg($\mathcal{X}$) and it is defined in the paper like so:

Let alg($\mathcal{X}$) denote the minimal sub-algebra of $\mathbb{R}^n$ containing the set $\mathcal{X}$.

In example 1 in the paper, the authors give a set $\mathcal{R}$ and the resulting alg($\mathcal{R}$) like this: $$ \begin{aligned} & \mathcal{R} = \text{span}\{\begin{bmatrix} 1/5 & 1/5 & 3/5 \end{bmatrix}\}\\ & \text{alg}(\mathcal{R}) = \text{span}\{\begin{bmatrix} 1 \ 1 \ 0 \end{bmatrix}, \begin{bmatrix} 0 \ 0 \ 1 \end{bmatrix}\} \end{aligned} $$

They are all column vectors but I can't seem to give them correct format. It's my first time using this site and Sagemath. Please refer to example 1 at page 8 in the paper.

I need help explaining the definition of alg($\mathcal{X}$). What is "the minimal sub-algebra of $\mathbb{R}^n$ containing the set $\mathcal{X}$"? And how do I turn this into sagemath code? I need a function that input a span like $\mathcal{R}$ and output alg($\mathcal{R}$).