This arbitrary-precision PHP function computes the time in seconds that it takes to accelerate from rest to reach a given distance in meters. It also takes into account the time-dilating affect of general relativity.
/* =========================================================================== This function returns the statistics pertaining to accelerating from rest until reaching distance (D meters) at a specified rate (m/s^2), taking into account the effect of relativistic time dilation in the case of extreme values, such as interstellar or intergalactic distances. Given SI arguments: DistM = Distance accelerated (meters) Accel = Rate of acceleration (meters/s^2) ----------------------------------------------------------------- The formulas below were derived from basic relativistic geometry. Returns string of space-delimited values: 'm a D T A b t' Where: D = Distance in light seconds equivalent to (DistM). = DistM / 299792458 a = Rate of acceleration (m/s^2) experienced by traveler. g = Standard gravitational acceleration rate on Earth = 9.80665 m/s^2 A = Relativistic acceleration potential. = a * T / c = a * T / 299792458 If there was no natural speed limit, then this would be the the relativistic speed we would achieve after accelerating at rate (a) for (T) seconds, which can reach values greater than the speed of light, which is 'impossible', hence the use of the term 'potential'. T = Earth observer (static frame) time interval to reach (D). = sqrt(D*D + 2*D/A) The Earth is taken to be static relative to the moving traveler. b = Relativistic speed (v/c) reached at distance (D). = T / (D + 1/A) t = Traveler's proper (moving frame) time interval to reach (D). = log((1 + b) / sqrt(1 - b*b)) / A Where log(x) refers to the natural (Napierian) logarithm. (T - t) will always equate to >= 0 due to relativistic time dilation. Relativistic time dilation has been experimentally confirmed. ERRORS: Error message returned on invalid argument. =========================================================================== */ function bc_Time_to_Accel_to_Dist ($DistMetersStr, $AccelStr='9.80665') { $Q = 64; // Set internal working decimals limit. $c = '299792458'; // Speed of light m/s // Read distance in meters and acceleration rate arguments. $m = trim($DistMetersStr); // m $a = trim($AccelStr); // m/s^2 $S = '1'; // Error if invalid argument. if (!Is_Numeric($m) or !Is_Numeric($a)) {return "ERROR:\n\nBoth arguments must be numeric.";} // Compute light seconds distance from meters. $D = bcDiv($m, bcMul($c, $S, $Q),$Q); // Compute relativistic acceleration potential. $A = bcDiv(bcMul($a, $S, $Q), $c, $Q); $_D2 = bcMul($D, $D, $Q); $_2D = bcMul('2', $D, $Q); $_2D_over_A = bcDiv($_2D, $A, $Q); // Compute Earth time interval to accelerate // to distance D light-time units. $T = bcSqRt(bcAdd($_D2, $_2D_over_A, $Q),$Q); // Relativistic speed beta (v/c) achieved at distance (D). $b = bcDiv($T, bcAdd($D, bcDiv('1', $A, $Q), $Q),$Q); // beta $b2 = bcMul($b,$b, $Q); $_1_minus_b2 = bcSub('1', bcMul($b,$b, $Q),$Q); $k = bcDiv(bcAdd('1', $b, $Q), bcsqrt($_1_minus_b2, $Q),$Q); // Compute traveler's proper time to // reach final distance (D). This time // value is limited to double-precision. $t = log($k) / $A; // Do some output formatting. $Q = 32; // Output decimals limit. $m = RTrim(RTrim(bcAdd('0', $m, $Q), '0'), '.'); $a = RTrim(RTrim(bcAdd('0', $a, $Q), '0'), '.'); $D = RTrim(RTrim(bcAdd('0', $D, $Q), '0'), '.'); $T = RTrim(RTrim(bcAdd('0', $T, $Q), '0'), '.'); $A = RTrim(RTrim(bcAdd('0', $A, $Q), '0'), '.'); $b = RTrim(RTrim(bcAdd('0', $b, $Q), '0'), '.'); $t = RTrim(RTrim(bcAdd('0', $t, $Q), '0'), '.'); return "$m $a $D $T $A $b $t"; } // end of bc_Time_to_Accel_to_Dist (...)