Photon redshift for Schwarzschild black holes https://en.wikipedia.org/wiki/Gravitational_redshift 2 G M Rs = ------- c^2 R1 (R2 - Rs) f1 = f2 sqrt[ -------------- ] R2 (R1 - Rs) f2 - f1 z = --------- f1 Where Rs = Schwarzschild radius M = black hole mass G = gravitational constant c = speed of light in vacuum f1 = observed frequency R1 = observer distance from singularity (ie. center of mass of the black hole), > Rs f2 = emitted frequency R2 = emitter distance from singularity, > Rs z = redshift [-z = blueshift] Calculated in two phases, phase 1: Photon redshift from different emitter distances as observed at R1. Emitter starts at 1e12 meters away from the black hole, and approaches all the way to 1e-24m (billionth of a proton radius, or so). For each emitter distance, observed frequency [Hz] and redshift [dimensionless] are displayed. phase 2: Photon redshift from selected emitter distance at different observer distances. Observer starts at 1 meter away from the event horizon, and gains distance up the decades all the way to 1e18m (>100ly) For each observer distance, observed frequency [Hz] and redshift [dimensionless] are displayed. Input as optional GET parameters [with default]: M = mass in Msols [1] R1 = observer distance in meters [1.49597871e11] f2 = emitted frequency in Hertz' [1e20] d = emitter distance from event horizon in phase 2 in meters [0.001] DIGITS = request more decimal places for calculations [128] Examples: Solar mass black hole observed from Earth: http://rubor.org/schwarzschildarb.php Same but with an emitted visible photon: http://rubor.org/schwarzschildarb.php?f2=0.565e15 Sgr A* from 1au: http://rubor.org/schwarzschildarb.php?M=4.1e6 Gargantua from 3au (~Miller's planet): http://rubor.org/schwarzschildarb.php?M=1e8&R1=4.48e11 10 Sols & emit from 1m above EH in phase 2: http://rubor.org/schwarzschildarb.php?M=10&d=1 Msol, visible, emitted from Rsol: http://rubor.org/schwarzschildarb.php?f2=0.565e15&d=6.957e8 Solar mass observed from Venus, emit a microwave: http://rubor.org/schwarzschildarb.php?f2=2.45e9&R1=108208930000 ESA 360° black hole visualisation EOF; bcscale(128); if (isset($_GET['DIGITS'])) bcscale(max(128,min(intval($_GET['DIGITS']), 10000))); if (php_sapi_name() != "cli" ) { echo "
\n";
  echo $README;
}

$au = sprintf("%f",floatval(1.49597871e11)); // m 
$Msol = sprintf("%f",floatval(1.9891e30)); // kg

// defaults

$f2 = 1e20; // emitted frequency, Hz
if (isset($_GET['f2']))
 $f2 = sprintf("%f",floatval($_GET['f2']));

$R1 = bcmul($au,"1"); // observer distance, meters 
if (isset($_GET['R1']))
  $R1 = sprintf("%f",floatval(trim($_GET['R1'],"+")));

$Mtest = bcmul($Msol,"1"); // black hole mass, kg
if (isset($_GET['M'])) {
  $Mtest = bcmul(sprintf("%.53f", floatval($_GET['M'])),$Msol);
  error_log("Input M: " . floatval($_GET['M']));
}
error_log("M = " . $Mtest);

// calculate the EH radius
$Rs = schwarzschild($Mtest); // got it, in meters.
error_log("Rs = " . floatval($Rs));
if (floatval($Rs) >= floatval($R1) ) // sanity
  $R1 = bcmul($Rs,"2.0");

error_log("R1 = " . $R1);
// phase 1:  redshift from different emission heights
echo "

";
echo "Mass M = " . $Mtest/$Msol . " Msol\n"
     ."Schwarzschild radius Rs = " . $Rs/$au . " a.u. (" . $Rs/1000 . "km)\n";;

echo "\nPhase 1:  emitter moves towards event horizon\n"
     ."Emission distance R2 = Rs + d (variable)\n"
     ."Observer distance R1 = " . sprintf("%e",$R1) . "m\n"
     ."Emitted frequency f2 = " . $f2 . "Hz\n\n"
    ."    d [m]          f1 [Hz]        z \n";
$p1s = sprintf("%f",max(1e12,$R1));
if (isset($_GET['p1s']))
  $p1s = sprintf("%.53f", floatval($_GET['p1s']));
$p1d = 10;
if (isset($_GET['p1d']))
  $p1d = sprintf("%.53f", floatval($_GET['p1d']));
if ( $p1d == 0 )
  $p1d = 2;
$p1e = 1e-25; 
if (isset($_GET['p1e']))
  $p1e = sprintf("%.53f", floatval($_GET['p1e']));
for ($d = $p1s; $d > $p1e; $d = bcdiv("$d","$p1d") ) { // loop over emitter distances
  $R2 = bcadd("$Rs","$d");
  $Rs2 = bcsub("$R2","$Rs");
  $Rs1 = bcsub("$R1","$Rs");
  $f1 = $f2*floatval(bcsqrt(bcdiv(bcmul($R1,$Rs2),bcmul($R2,$Rs1))));
  if ($f1 > 0) {
    $z = bcdiv(sprintf("%.53f","".$f2-$f1.""),sprintf("%.53f",$f1));
    echo sprintf("%e",$d) . "\t " . sprintf("%e",$f1) 
    . "\t" . sprintf("%e",$z) . " (" . sprintf("%.2f",$z) . ")\n";
  }
  else {
    $z = "inf";
    echo sprintf("%e",$d) . "\t " . sprintf("%e",$f1) 
    . "\t" . $z . "\n";
  }
 }

// phase 2:  redshift from different observer heights

$d = "0.001"; // how many meters above Rs to emit at phase 2
if (isset($_GET['d'])) {
  error_log(sprintf("%.53f",floatval($_GET['d'])));
  $d = bcadd("".sprintf("%.53f",floatval($_GET['d']))."","0.0");
  error_log($d);
}

echo "\n\n"
    . "\nPhase 2:  observer moves away from the horizon"
    ."\nEmission distance R2 = Rs + " . sprintf("%e",$d) . "m\nObserver distance R1 = variable\nEmitted frequency f2 = " . $f2 . "Hz\n\n"
    ."R1 = Rs + [m]      f1 [Hz]        z \n";

$p2s = sprintf("%.53f", "1");
if (isset($_GET['p2s']))
  $p2s = sprintf("%.53f", floatval($_GET['p2s']));
$p2d = 10;
if (isset($_GET['p2d']))
  $p2d = sprintf("%.53f", floatval($_GET['p2d']));
if ($p2d <= 1 )
  $p2d = 2;
$p2e = 1e19;
if (isset($_GET['p2e']))
  $p2e = sprintf("%.53f", floatval($_GET['p2e']));
for ($i = $p2s; $i <= $p2e; $i = bcmul("$i","$p2d") ) { // loop over obser distances
  $R1 = bcadd("$Rs", "$i");
  $R2 = bcadd("$Rs","$d"); // change this to emit closer to/farther from event horizon
  $Rs2 = bcsub("$R2","$Rs");
  $Rs1 = bcsub("$R1","$Rs");
  $f1 = $f2*floatval(bcsqrt(bcdiv(bcmul($R1,$Rs2),bcmul($R2,$Rs1))));
  $z = bcdiv(sprintf("%.53f","".$f2-$f1.""),sprintf("%.53f",$f1));
  echo sprintf("%e",bcsub($R1,$Rs)) . "\t" . sprintf("%e",$f1)
    . "\t" . sprintf("%.2f", $z) . "\n";

 }

if (php_sapi_name() != "cli" ) {
  echo "

\n"; echo "
\n";
  echo "
"; echo "\n Bonus GET parameters for controlling the loops:\n" . " p1s = phase 1 loop start, 'outerspace', f.e. 1e24\n" . " p1d = phase 1 loop step divider, f.e. 10 or 1e1 (must be > 1)\n" . " p1e = phase 1 loop end, ~event horizon, f.e. 1e-32\n" . "\n" . " p2s = phase 2 loop start, ~event horizon, f.e. 1e-24\n" . " p2d = phase 2 loop step multiplier, f.e. 10 or 1e1\n" . " p2e = phase 2 loop end, 'outerspace', f.e. 1e32\n" . "\n" . " Input is handled via PHPs sprintf, which limits \n" . " numerical range for mass/distance to about 53 decades;\n" . " the proton mass divided by solar mass is < 1e-57, and therefore\n" . " proton horizon is intractable (until I maybe fix it).\n" . "\n" . "Example: http://rubor.org/schwarzschildarb.php?p1s=1e18&p1d=2&p1e=1e-32" . "\n\n" . "Creative Commons Attribution by jussi.kantola @ gmail.com 2017" . "\nVisualizations by Professor Andrew Hamilton and used with permission." . "\n" . "No guarantees on accuracy or correctness of the results. source code."; echo "
\n"; } // return schwarzschild radius for mass $M function schwarzschild($M) { $G = bcmul("6.67408","0.00000000001"); // m^3/kg*s^2 $c = 299792458; // m / s //return floatval(2.0*$G*floatval(abs($M))/floatval(pow($c,2))); $a = bcmul("2.0",$G); $c2 = bcpow("$c","2.0"); $b = bcdiv($M,$c2); error_log($a . " " . $b . " " . $c2); return bcmul($a,$b); } ?>