Is there a specific requirement for Mathematica? It is know that this software is more useful for symbolic manipulation, rather than numerical calculation. There is a spectrum of codes out there that will teach you LHS. In itself, the baseline algorithm is straightforward. Its efficient implementation is also not so difficult to grasp assuming enough time is spent on it.