55of an object moving at speed v1 relative to a frame that is itself moving at velocity v
66relative to an observer. I take the last one to be strictly lower than the speed of
77light.
8- The formula is v2 = (v1 + v)/(1 + v1 * v / c^ 2)
8+ The formula is v2 = (v1 + v)/(1 + v1 * v / c** 2)
99v1 - speed of the object relative to a moving frame
1010v - speed of the moving frame
1111c - speed of light in the vacuum
1212v2 - speed of the object relative to an observer
1313"""
1414
1515
16- def relativistic_velocity_summation (v1 : float , v : float ) -> float :
16+ def relativistic_velocity_summation (
17+ object_velocity : float , frame_velocity : float
18+ ) -> float :
1719 """
1820 >>> relativistic_velocity_summation(200000000, 200000000)
1921 276805111.0636436
@@ -24,12 +26,15 @@ def relativistic_velocity_summation(v1: float, v: float) -> float:
2426 ...
2527 ValueError: Speeds must not exceed light speed...
2628 """
27- if v1 > c or v >= c or v1 < - c or v <= - c :
29+ if (object_velocity > c or frame_velocity >= c or
30+ object_velocity < - c or frame_velocity <= - c ):
2831 raise ValueError (
2932 "Speeds must not exceed light speed, and "
3033 "the frame speed must be lower than the light speed!"
3134 )
32- return (v1 + v ) / (1 + v1 * v / (c * c ))
35+ numerator = object_velocity + frame_velocity
36+ denominator = 1 + object_velocity * frame_velocity / c ** 2
37+ return numerator / denominator
3338
3439
3540if __name__ == "__main__" :
0 commit comments