simplify sqrt, xpart, ypart in Javascript when possible