EDIT:
The equation in the comment is wrong, but the one in the actual script is right, i think