New Mathematica code.

Mathematica code with extension m to avoid the problems of sharing
notebooks