(***********************  filename: nbsolveAzeroBR0.m  ***********************)

(*****************************************************************************)
(*                                                                           *)
(*  This Mathematica program takes from nbdata.m and the user inputs         *)
(*  compatible with A = 0 and computes in terms of the input parameters      *)
(*  H0, Q0, and Hmax the parameters A, B, R0 that satisfy the equations      *)
(*                                                                           *)
(*                          2                                                *)
(*                        H0    A   3 k    B                                 *)
(*                        --- = - - --- - --- ,                              *)
(*                         2    3     2     6                                *)
(*                        c         R0    R0                                 *)
(*                                                                           *)
(*                          2             3/2                                *)
(*                      Hmax    A   2 (-k)                                   *)
(*                      ----- = - + --------- ,                              *)
(*                        2     3       1/2                                  *)
(*                       c           3 B                                     *)
(*                                                                           *)
(*                                   2      4                                *)
(*                                  c  (k R0  + B)                           *)
(*  and                    Q0 = 1 + -------------- ,                         *)
(*                                       2   6                               *)
(*                                     H0  R0                                *)
(*                                                                           *)
(*  and computes from them other parameters of interest.                     *) 
(*                                                                           *)
(*****************************************************************************)

$MaxPrecision = Infinity
$MaxExtraPrecision = Infinity

USimplify[x_] := Simplify[x, Assumptions -> {Meter > 0, Centimeter > 0,
                                             Second > 0, Year > 0}]

(*
t0 := present epoch in seconds

H0 := H(t0)
Q0 := Q(t0)
R0 := R(t0)

 X := H0/c
 Y := Hmax/c

X^2 = H0^2/c^2
    = -k/R0^2 - B/(3 R0^6)

Y^2 = Hmax^2/c^2
    = 2 (-k)^(3/2)/(3 Sqrt[B])
*)

Clear[X, Y, Z, A, B, k0, R0, B0]

X = H0sec/c; Y = Hmaxsec/c;

A = 0

B = 4 (-k)^3/(9 Y^4)

Q0 = USimplify[(2 B/(3 X^2 R0^6))]

(* The formula for R0sqr was obtained from solving the X^2 equation for R^2  *)
(* in an ancillary Mathematica session.                                      *)

R0sqr = USimplify[(-k/(3 X^2)) (1 + Cos[theta/3] + Sqrt[3] Sin[theta/3])]

R0 = USimplify[Sqrt[R0sqr]]

theta = Pi/2 - USimplify[ArcTan[(2 X^4 - Y^4)/(2 X^2 Sqrt[Y^4 - X^4])]]

RHmax = (B/(-k))^(1/4)

Q[R_] := 1 + c^2 (k R^4 + B)/(H[R]^2 R^6)

H[R_] := c Sqrt[(-3 k R^4 - B)/(3 R^6)]


Print[StringForm[" "]]

Print[StringForm["`1` = ``,     `3` = ``,     \!\(R\_0\) = ``",
                  iA, N[N[A,1000]], iB, N[N[B,1000]], N[N[R0,1000]] ]]

Print[StringForm[" "]]

Print[StringForm[
         "\!\(c\^2\) `1` = ``,     \!\(c\^2\) `3` = ``,     \!\(Q\_0\) = ``",
          iA, N[N[c^2 A,1000]],    iB, N[N[c^2 B,1000]],    N[N[Q0,1000]]    ]]

(* The formula for Rmin was obtained by solving the equation                 *)
(*                                                                           *)
(*            (1/c^2) H^2(R) = (-3 k R^4 - B)/(3 R^6) = 0                    *)
(*                                                                           *)
(* for R.                                                                    *)

Rmin = (B/(-3 k))^(1/4)

Print[StringForm[" "]]

Print[StringForm["\!\(R\_min\) = ``,     \!\(R\_\!\(H\_max\)\) = ``",
                  N[N[Rmin,1000]]  ,     N[N[RHmax,1000]]            ]]

Print[StringForm[" "]]

Print[StringForm[
 "\!\(R\_\!\(H\_max\)\)/\!\(R\_min\) = ``,     \!\(R\_0\)/\!\(R\_min\) = ``",
  N[RHmax/Rmin,6]                        ,     N[R0/Rmin,6]                  ]]

Print[StringForm[" "]]

Print[StringForm["`1`/\!\(R\_min\%2\) = curvature of space at bounce = ``",
                  ik, N[N[k/Rmin^2,1000]]                                  ]]

Print[StringForm[" "]]

Print[StringForm[StringReplace["\!\(k\_0\) = `1`/\!\(R\_0\%2\)
                                = curvature of space at present epoch = ``",
                               Whitespace -> " "], ik, N[N[k/R0sqr,1000]]   ]]


Print[StringForm[" "]]

newtimeused = TimeUsed[] - totaltimeused

totaltimeused = totaltimeused + newtimeused

Print[StringForm["Time used this run  = `` = ``",
                  newtimeused seconds, (newtimeused/60) minutes]]

Print[StringForm["Total time used = `` = ``",
                  totaltimeused seconds, (totaltimeused/60) minutes]]

Print[StringForm["Memory in use = ``",
                  N[MemoryInUse[]/2^20,7] megabytes]]

(**********************  End of file nbsolveAzeroBR0.m  **********************)
