#!/usr/bin/perl
#
# Use a very basic model -- Lambda = 0 -- to compute
#   the proper distance for a given redshift
#   and omega_matter.
#
# MWR 5/9/2013

$debug = 1;

# speed of light (m/s)
$c = 299792458;
# number of meters in Mpc
$Mpc_m = 3.08567758E22;
# Hubble constant, km/s/Mpc
$H0 = 70;
# Hubble constant, in 1/s
$H0_Hz = ($H0*1E3)/$Mpc_m;
if ($debug > 0) {
  printf " H0 = %6.1f km/s/Mpc = %10.4e 1/s \n", $H0, $H0_Hz;
}

# omega_matter
$omega_m = 0.25;


$start_z = 0.1;
$end_z = 10.0;
$d_z = 0.1;

for ($z = $start_z; $z < $end_z; $z += $d_z) {

  $factor = (2.0*$c) / ($H0_Hz);
  $x1 = (1.0 / (1 + $z) );
  $x2 = (1.0 / ($omega_m*$omega_m) );
  $x3 = $omega_m*$z;
  $x4 = (2.0 - $omega_m);
  $x5 = sqrt(1.0 + $omega_m*$z) - 1;

  $dist = $factor*$x1*$x2*(   $x3 - ($x4*$x5)   );
  
  printf "  %7.3f  %10.4e m  %10.4f Mpc \n",
     $z, $dist, $dist/$Mpc_m;

}


exit 0;
