Last active
August 29, 2015 14:00
-
-
Save simsicon/11324090 to your computer and use it in GitHub Desktop.
Relative Time Dilation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# http://en.wikipedia.org/wiki/Time_dilation | |
# | |
C = 300000.0 | |
SECONDS_IN_YEAR = 365 * 24 * 3600 | |
def calculate(v, delta_t) | |
relative_v = ( v * v ) / ( C * C ) | |
denominator = Math.sqrt( 1 - relative_v ).to_f | |
numerator = delta_t.to_f | |
numerator / denominator | |
end | |
def output(*args) | |
result = calculate(*args) | |
%Q[ | |
Travel in space at speed of #{ args[0].to_f } m/s | |
for #{ ( args[1] / SECONDS_IN_YEAR ).to_f } years | |
the relative time dilation would be #{ ( result / SECONDS_IN_YEAR ) } years. | |
] | |
end | |
args = [ ( 1 / 3.0 ) * C, 20 * SECONDS_IN_YEAR ] # 1/3 C for 20 years | |
puts output(*args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment