I changed math.pow to d*d for efficiency
Merge pull request #1 from AlasdairF/master

change math.pow to d*d for efficiency