Skip to content

Instantly share code, notes, and snippets.

@liamlah
Created February 11, 2012 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liamlah/1797709 to your computer and use it in GitHub Desktop.
Save liamlah/1797709 to your computer and use it in GitHub Desktop.
Lorentz mass equation
import math
speedoflight = 3e8
print "lets work out the mass of something moving at a speed near the speed of light (C)"
print "what is the initial mass of your object in kg?"
initmass = float(raw_input())
print "what is the velocity of your object in m/s?\n(note: C is 3e8, your input can have up to 17 digits before rounding.)"
velocity = float(raw_input())
if velocity == 3e8:
print "Watch out, you are trying to divide by zero! Try again."
else:
finalmass = initmass / math.sqrt( 1.00 - math.pow(velocity, 2) / math.pow(speedoflight, 2))
print "the mass of your object is %rkg" % (finalmass)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment