Adding phasetransition.m which I forgot to include in original commit