Calculate the Lorentz factor y = 1 / √(1 - v²/c²) for a given velocity >>> gamma(4) 1.0000000000000002 >>> gamma(1e5) 1.0000000556325075 >>> gamma(3e7) 1.005044845777813 >>> gamma(2.8e8) 2.7985595722318277 >>> gamma(299792451) 4627.49902669495 >>> gam
(velocity: float)
| 62 | |
| 63 | |
| 64 | def gamma(velocity: float) -> float: |
| 65 | """ |
| 66 | Calculate the Lorentz factor y = 1 / √(1 - v²/c²) for a given velocity |
| 67 | >>> gamma(4) |
| 68 | 1.0000000000000002 |
| 69 | >>> gamma(1e5) |
| 70 | 1.0000000556325075 |
| 71 | >>> gamma(3e7) |
| 72 | 1.005044845777813 |
| 73 | >>> gamma(2.8e8) |
| 74 | 2.7985595722318277 |
| 75 | >>> gamma(299792451) |
| 76 | 4627.49902669495 |
| 77 | >>> gamma(0.3) |
| 78 | Traceback (most recent call last): |
| 79 | ... |
| 80 | ValueError: Speed must be greater than or equal to 1! |
| 81 | >>> gamma(2 * c) |
| 82 | Traceback (most recent call last): |
| 83 | ... |
| 84 | ValueError: Speed must not exceed light speed 299,792,458 [m/s]! |
| 85 | """ |
| 86 | return 1 / sqrt(1 - beta(velocity) ** 2) |
| 87 | |
| 88 | |
| 89 | def transformation_matrix(velocity: float) -> np.ndarray: |
no test coverage detected