# Zassenhaus algorithm

In mathematics, the Zassenhaus algorithm[1] is a method to calculate a basis for the intersection and sum of two subspaces of a vector space. It is named after Hans Zassenhaus, but no publication of this algorithm by him is known.[2] It is used in computer algebra systems.[3]

## Algorithm

### Input

Let V be a vector space and U, W two finite-dimensional subspaces of V with the following spanning sets:

${\displaystyle U=\langle u_{1},\ldots ,u_{n}\rangle }$

and

${\displaystyle W=\langle w_{1},\ldots ,w_{k}\rangle .}$

Finally, let ${\displaystyle B_{1},\ldots ,B_{m}}$  be linearly independent vectors so that ${\displaystyle u_{i}}$  and ${\displaystyle w_{i}}$  can be written as

${\displaystyle u_{i}=\sum _{j=1}^{m}a_{i,j}B_{j}}$

and

${\displaystyle w_{i}=\sum _{j=1}^{m}b_{i,j}B_{j}.}$

### Output

The algorithm computes the base of the sum ${\displaystyle U+W}$  and a base of the intersection ${\displaystyle U\cap W}$ .

### Algorithm

The algorithm creates the following block matrix of size ${\displaystyle ((n+k)\times (2m))}$ :

${\displaystyle {\begin{pmatrix}a_{1,1}&a_{1,2}&\cdots &a_{1,m}&a_{1,1}&a_{1,2}&\cdots &a_{1,m}\\\vdots &\vdots &&\vdots &\vdots &\vdots &&\vdots \\a_{n,1}&a_{n,2}&\cdots &a_{n,m}&a_{n,1}&a_{n,2}&\cdots &a_{n,m}\\b_{1,1}&b_{1,2}&\cdots &b_{1,m}&0&0&\cdots &0\\\vdots &\vdots &&\vdots &\vdots &\vdots &&\vdots \\b_{k,1}&b_{k,2}&\cdots &b_{k,m}&0&0&\cdots &0\end{pmatrix}}}$

Using elementary row operations, this matrix is transformed to the row echelon form. Then, it has the following shape:

${\displaystyle {\begin{pmatrix}c_{1,1}&c_{1,2}&\cdots &c_{1,m}&\bullet &\bullet &\cdots &\bullet \\\vdots &\vdots &&\vdots &\vdots &\vdots &&\vdots \\c_{q,1}&c_{q,2}&\cdots &c_{q,m}&\bullet &\bullet &\cdots &\bullet \\0&0&\cdots &0&d_{1,1}&d_{1,2}&\cdots &d_{1,m}\\\vdots &\vdots &&\vdots &\vdots &\vdots &&\vdots \\0&0&\cdots &0&d_{\ell ,1}&d_{\ell ,2}&\cdots &d_{\ell ,m}\\0&0&\cdots &0&0&0&\cdots &0\\\vdots &\vdots &&\vdots &\vdots &\vdots &&\vdots \\0&0&\cdots &0&0&0&\cdots &0\end{pmatrix}}}$

Here, ${\displaystyle \bullet }$  stands for arbitrary numbers, and the vectors ${\displaystyle (c_{p,1},c_{p,2},\ldots ,c_{p,m})}$  for every ${\displaystyle p\in \{1,\ldots ,q\}}$  and ${\displaystyle (d_{p,1},\ldots ,d_{p,m})}$  for every ${\displaystyle p\in \{1,\ldots ,\ell \}}$  are nonzero.

Then ${\displaystyle (y_{1},\ldots ,y_{q})}$  with

${\displaystyle y_{i}:=\sum _{j=1}^{m}c_{i,j}B_{j}}$

is a basis of ${\displaystyle U+W}$  and ${\displaystyle (z_{1},\ldots ,z_{\ell })}$  with

${\displaystyle z_{i}:=\sum _{j=1}^{m}d_{i,j}B_{j}}$

is a basis of ${\displaystyle U\cap W}$ .

### Proof of correctness

First, we define ${\displaystyle \pi _{1}:V\times V\to V,(a,b)\mapsto a}$  to be the projection to the first component.

Let ${\displaystyle H:=\{(u,u)\mid u\in U\}+\{(w,0)\mid w\in W\}\subseteq V\times V.}$  Then ${\displaystyle \pi _{1}(H)=U+W}$  and ${\displaystyle H\cap (0\times V)=0\times (U\cap W)}$ .

Also, ${\displaystyle H\cap (0\times V)}$  is the kernel of ${\displaystyle {\pi _{1}|}_{H}}$ , the projection restricted to H. Therefore, ${\displaystyle \dim(H)=\dim(U+W)+\dim(U\cap W)}$ .

The Zassenhaus algorithm calculates a basis of H. In the first m columns of this matrix, there is a basis ${\displaystyle y_{i}}$  of ${\displaystyle U+W}$ .

The rows of the form ${\displaystyle (0,z_{i})}$  (with ${\displaystyle z_{i}\neq 0}$ ) are obviously in ${\displaystyle H\cap (0\times V)}$ . Because the matrix is in row echelon form, they are also linearly independent. All rows which are different from zero (${\displaystyle (y_{i},\bullet )}$  and ${\displaystyle (0,z_{i})}$ ) are a basis of H, so there are ${\displaystyle \dim(U\cap W)}$  such ${\displaystyle z_{i}}$ s. Therefore, the ${\displaystyle z_{i}}$ s form a basis of ${\displaystyle U\cap W}$ .

## Example

Consider the two subspaces ${\displaystyle U=\left\langle \left({\begin{array}{r}1\\-1\\0\\1\end{array}}\right),\left({\begin{array}{r}0\\0\\1\\-1\end{array}}\right)\right\rangle }$  and ${\displaystyle W=\left\langle \left({\begin{array}{r}5\\0\\-3\\3\end{array}}\right),\left({\begin{array}{r}0\\5\\-3\\-2\end{array}}\right)\right\rangle }$  of the vector space ${\displaystyle \mathbb {R} ^{4}}$ .

Using the standard basis, we create the following matrix of dimension ${\displaystyle (2+2)\times (2\cdot 4)}$ :

${\displaystyle \left({\begin{array}{rrrrrrrr}1&-1&0&1&&1&-1&0&1\\0&0&1&-1&&0&0&1&-1\\\\5&0&-3&3&&0&0&0&0\\0&5&-3&-2&&0&0&0&0\end{array}}\right).}$

Using elementary row operations, we transform this matrix into the following matrix:

${\displaystyle \left({\begin{array}{rrrrrrrrr}1&0&0&0&&\bullet &\bullet &\bullet &\bullet \\0&1&0&-1&&\bullet &\bullet &\bullet &\bullet \\0&0&1&-1&&\bullet &\bullet &\bullet &\bullet \\\\0&0&0&0&&1&-1&0&1\end{array}}\right)}$  (Some entries have been replaced by "${\displaystyle \bullet }$ " because they are irrelevant to the result.)

Therefore ${\displaystyle \left(\left({\begin{array}{r}1\\0\\0\\0\end{array}}\right),\left({\begin{array}{r}0\\1\\0\\-1\end{array}}\right),\left({\begin{array}{r}0\\0\\1\\-1\end{array}}\right)\right)}$  is a basis of ${\displaystyle U+W}$ , and ${\displaystyle \left(\left({\begin{array}{r}1\\-1\\0\\1\end{array}}\right)\right)}$  is a basis of ${\displaystyle U\cap W}$ .