Finding a basis for a submodule 
Let $F$ be the $\mathbb{Z}$-module $\mathbb{Z}^{3}$ and let $N$  be the submodule generated by $\{(4,-4,4),(-4,4,8),(16,20,40)\}$. Find a basis $\left\{ f_{1},f_{2},f_{3}\right\}$ for $F$ and integers $d_{1},d_{2},d_{3}$ such that $d_{1}\mid d_{2}\mid d_{3}$ and $\left\{d_{1}f_{1},d_{2}f_{2},d_{3}f_{3}\right\}$ is a basis for $N$.

Now I found $d_1 = 4 , d_2 = 12$ and $d_3 = 36$, but I don't know how to find $f_1 , f_2 , f_3$.
 A: As this is a standard exercise I only outline the basic theory and steps. Let $A$ be a 3x3 matrix with your three generators as rows. If your preference is to use columns, that is very much ok, you simply need to transpose everything I say below. Do remember that taking the transpose reverses the order of matrix multiplication.
The algorithm leading to Smith normal form gives you two unimodular matrices, $P$ and $Q$, such that $PAQ=D$ with
$$D=\left(\begin{array}{ccc}d_1&0&0\\0&d_2&0\\0&0&d_3\end{array}\right).$$
The rows of the product matrix $PA$ are linear combinations of the rows of $A$, so as $P$ is unimodular, they form another basis of $N$. Here $PA=DQ^{-1}$, so the rows of $DQ^{-1}$ form a basis of $N$ as well. On the other hand $Q^{-1}$ is unimodular, so its rows form a basis of $\mathbf{Z}^3$. I leave it to you as an exercise to find how the rows of $DQ^{-1}$ are related to the rows $Q^{-1}$. Trust me, it is crucial to your question!
How to find the unimodular matrices $P$ and $Q$? Remember that when you perform an elementary row operation (=swap two rows, add a scalar multiple of one to another,...) to a matrix, you are multiplying it with an elementary matrix from the left. Several such operations are carried out, when looking for the Smith normal form. All these operations amount to multiplying whatever you had before from the left. Therefore the row operations are the building blocks of the matrix $P$. Similarly elementary column operations are equivalent to multiplying a matrix with an elementary matrix from the right. Thus the column operations that you perform while computing the Smith normal form are the building blocks of the matrix $Q$.
