Javascript Function Length Formula In Physics