
(FPCore (t l Om Omc) :precision binary64 (asin (sqrt (/ (- 1.0 (pow (/ Om Omc) 2.0)) (+ 1.0 (* 2.0 (pow (/ t l) 2.0)))))))
double code(double t, double l, double Om, double Omc) {
return asin(sqrt(((1.0 - pow((Om / Omc), 2.0)) / (1.0 + (2.0 * pow((t / l), 2.0))))));
}
real(8) function code(t, l, om, omc)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: omc
code = asin(sqrt(((1.0d0 - ((om / omc) ** 2.0d0)) / (1.0d0 + (2.0d0 * ((t / l) ** 2.0d0))))))
end function
public static double code(double t, double l, double Om, double Omc) {
return Math.asin(Math.sqrt(((1.0 - Math.pow((Om / Omc), 2.0)) / (1.0 + (2.0 * Math.pow((t / l), 2.0))))));
}
def code(t, l, Om, Omc): return math.asin(math.sqrt(((1.0 - math.pow((Om / Omc), 2.0)) / (1.0 + (2.0 * math.pow((t / l), 2.0))))))
function code(t, l, Om, Omc) return asin(sqrt(Float64(Float64(1.0 - (Float64(Om / Omc) ^ 2.0)) / Float64(1.0 + Float64(2.0 * (Float64(t / l) ^ 2.0)))))) end
function tmp = code(t, l, Om, Omc) tmp = asin(sqrt(((1.0 - ((Om / Omc) ^ 2.0)) / (1.0 + (2.0 * ((t / l) ^ 2.0)))))); end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[Sqrt[N[(N[(1.0 - N[Power[N[(Om / Omc), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(2.0 * N[Power[N[(t / l), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{1 + 2 \cdot {\left(\frac{t}{\ell}\right)}^{2}}}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (t l Om Omc) :precision binary64 (asin (sqrt (/ (- 1.0 (pow (/ Om Omc) 2.0)) (+ 1.0 (* 2.0 (pow (/ t l) 2.0)))))))
double code(double t, double l, double Om, double Omc) {
return asin(sqrt(((1.0 - pow((Om / Omc), 2.0)) / (1.0 + (2.0 * pow((t / l), 2.0))))));
}
real(8) function code(t, l, om, omc)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: omc
code = asin(sqrt(((1.0d0 - ((om / omc) ** 2.0d0)) / (1.0d0 + (2.0d0 * ((t / l) ** 2.0d0))))))
end function
public static double code(double t, double l, double Om, double Omc) {
return Math.asin(Math.sqrt(((1.0 - Math.pow((Om / Omc), 2.0)) / (1.0 + (2.0 * Math.pow((t / l), 2.0))))));
}
def code(t, l, Om, Omc): return math.asin(math.sqrt(((1.0 - math.pow((Om / Omc), 2.0)) / (1.0 + (2.0 * math.pow((t / l), 2.0))))))
function code(t, l, Om, Omc) return asin(sqrt(Float64(Float64(1.0 - (Float64(Om / Omc) ^ 2.0)) / Float64(1.0 + Float64(2.0 * (Float64(t / l) ^ 2.0)))))) end
function tmp = code(t, l, Om, Omc) tmp = asin(sqrt(((1.0 - ((Om / Omc) ^ 2.0)) / (1.0 + (2.0 * ((t / l) ^ 2.0)))))); end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[Sqrt[N[(N[(1.0 - N[Power[N[(Om / Omc), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(2.0 * N[Power[N[(t / l), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{1 + 2 \cdot {\left(\frac{t}{\ell}\right)}^{2}}}\right)
\end{array}
NOTE: t should be positive before calling this function
(FPCore (t l Om Omc)
:precision binary64
(let* ((t_1 (- 1.0 (/ (/ Om Omc) (/ Omc Om)))))
(if (<= (/ t l) -1e+161)
(asin (* (sqrt t_1) (* (/ l t) (- (sqrt 0.5)))))
(if (<= (/ t l) 40000000.0)
(asin (sqrt (/ t_1 (+ 1.0 (* 2.0 (* (/ t l) (/ t l)))))))
(asin
(*
(/ (* l (sqrt 0.5)) t)
(sqrt (- 1.0 (* (/ Om Omc) (/ Om Omc))))))))))t = abs(t);
double code(double t, double l, double Om, double Omc) {
double t_1 = 1.0 - ((Om / Omc) / (Omc / Om));
double tmp;
if ((t / l) <= -1e+161) {
tmp = asin((sqrt(t_1) * ((l / t) * -sqrt(0.5))));
} else if ((t / l) <= 40000000.0) {
tmp = asin(sqrt((t_1 / (1.0 + (2.0 * ((t / l) * (t / l)))))));
} else {
tmp = asin((((l * sqrt(0.5)) / t) * sqrt((1.0 - ((Om / Omc) * (Om / Omc))))));
}
return tmp;
}
NOTE: t should be positive before calling this function
real(8) function code(t, l, om, omc)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: omc
real(8) :: t_1
real(8) :: tmp
t_1 = 1.0d0 - ((om / omc) / (omc / om))
if ((t / l) <= (-1d+161)) then
tmp = asin((sqrt(t_1) * ((l / t) * -sqrt(0.5d0))))
else if ((t / l) <= 40000000.0d0) then
tmp = asin(sqrt((t_1 / (1.0d0 + (2.0d0 * ((t / l) * (t / l)))))))
else
tmp = asin((((l * sqrt(0.5d0)) / t) * sqrt((1.0d0 - ((om / omc) * (om / omc))))))
end if
code = tmp
end function
t = Math.abs(t);
public static double code(double t, double l, double Om, double Omc) {
double t_1 = 1.0 - ((Om / Omc) / (Omc / Om));
double tmp;
if ((t / l) <= -1e+161) {
tmp = Math.asin((Math.sqrt(t_1) * ((l / t) * -Math.sqrt(0.5))));
} else if ((t / l) <= 40000000.0) {
tmp = Math.asin(Math.sqrt((t_1 / (1.0 + (2.0 * ((t / l) * (t / l)))))));
} else {
tmp = Math.asin((((l * Math.sqrt(0.5)) / t) * Math.sqrt((1.0 - ((Om / Omc) * (Om / Omc))))));
}
return tmp;
}
t = abs(t) def code(t, l, Om, Omc): t_1 = 1.0 - ((Om / Omc) / (Omc / Om)) tmp = 0 if (t / l) <= -1e+161: tmp = math.asin((math.sqrt(t_1) * ((l / t) * -math.sqrt(0.5)))) elif (t / l) <= 40000000.0: tmp = math.asin(math.sqrt((t_1 / (1.0 + (2.0 * ((t / l) * (t / l))))))) else: tmp = math.asin((((l * math.sqrt(0.5)) / t) * math.sqrt((1.0 - ((Om / Omc) * (Om / Omc)))))) return tmp
t = abs(t) function code(t, l, Om, Omc) t_1 = Float64(1.0 - Float64(Float64(Om / Omc) / Float64(Omc / Om))) tmp = 0.0 if (Float64(t / l) <= -1e+161) tmp = asin(Float64(sqrt(t_1) * Float64(Float64(l / t) * Float64(-sqrt(0.5))))); elseif (Float64(t / l) <= 40000000.0) tmp = asin(sqrt(Float64(t_1 / Float64(1.0 + Float64(2.0 * Float64(Float64(t / l) * Float64(t / l))))))); else tmp = asin(Float64(Float64(Float64(l * sqrt(0.5)) / t) * sqrt(Float64(1.0 - Float64(Float64(Om / Omc) * Float64(Om / Omc)))))); end return tmp end
t = abs(t) function tmp_2 = code(t, l, Om, Omc) t_1 = 1.0 - ((Om / Omc) / (Omc / Om)); tmp = 0.0; if ((t / l) <= -1e+161) tmp = asin((sqrt(t_1) * ((l / t) * -sqrt(0.5)))); elseif ((t / l) <= 40000000.0) tmp = asin(sqrt((t_1 / (1.0 + (2.0 * ((t / l) * (t / l))))))); else tmp = asin((((l * sqrt(0.5)) / t) * sqrt((1.0 - ((Om / Omc) * (Om / Omc)))))); end tmp_2 = tmp; end
NOTE: t should be positive before calling this function
code[t_, l_, Om_, Omc_] := Block[{t$95$1 = N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] / N[(Omc / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t / l), $MachinePrecision], -1e+161], N[ArcSin[N[(N[Sqrt[t$95$1], $MachinePrecision] * N[(N[(l / t), $MachinePrecision] * (-N[Sqrt[0.5], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(t / l), $MachinePrecision], 40000000.0], N[ArcSin[N[Sqrt[N[(t$95$1 / N[(1.0 + N[(2.0 * N[(N[(t / l), $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[ArcSin[N[(N[(N[(l * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] * N[Sqrt[N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] * N[(Om / Omc), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
t = |t|\\
\\
\begin{array}{l}
t_1 := 1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}\\
\mathbf{if}\;\frac{t}{\ell} \leq -1 \cdot 10^{+161}:\\
\;\;\;\;\sin^{-1} \left(\sqrt{t_1} \cdot \left(\frac{\ell}{t} \cdot \left(-\sqrt{0.5}\right)\right)\right)\\
\mathbf{elif}\;\frac{t}{\ell} \leq 40000000:\\
\;\;\;\;\sin^{-1} \left(\sqrt{\frac{t_1}{1 + 2 \cdot \left(\frac{t}{\ell} \cdot \frac{t}{\ell}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(\frac{\ell \cdot \sqrt{0.5}}{t} \cdot \sqrt{1 - \frac{Om}{Omc} \cdot \frac{Om}{Omc}}\right)\\
\end{array}
\end{array}
if (/.f64 t l) < -1e161Initial program 50.6%
unpow250.6%
clear-num50.6%
clear-num50.6%
frac-times50.6%
metadata-eval50.6%
Applied egg-rr50.6%
Taylor expanded in t around -inf 91.3%
mul-1-neg91.3%
associate-/l*91.2%
*-commutative91.2%
distribute-rgt-neg-in91.2%
unpow291.2%
unpow291.2%
times-frac99.5%
unpow299.5%
mul-1-neg99.5%
associate-/r/99.6%
associate-*r*99.6%
neg-mul-199.6%
Simplified99.6%
unpow299.6%
clear-num99.6%
un-div-inv99.6%
Applied egg-rr99.6%
if -1e161 < (/.f64 t l) < 4e7Initial program 98.6%
unpow298.6%
clear-num98.6%
frac-times96.1%
*-un-lft-identity96.1%
Applied egg-rr96.1%
unpow214.8%
clear-num14.8%
un-div-inv14.8%
Applied egg-rr96.1%
*-un-lft-identity96.1%
frac-times98.6%
clear-num98.6%
Applied egg-rr98.6%
if 4e7 < (/.f64 t l) Initial program 65.2%
Taylor expanded in t around inf 85.7%
unpow285.7%
unpow285.7%
frac-times99.5%
Applied egg-rr99.5%
Final simplification99.0%
NOTE: t should be positive before calling this function
(FPCore (t l Om Omc)
:precision binary64
(if (<= (pow (/ t l) 2.0) 5e+300)
(asin
(sqrt
(/
(- 1.0 (/ (/ Om Omc) (/ Omc Om)))
(+ 1.0 (* 2.0 (* (/ t l) (/ t l)))))))
(asin (/ (hypot 1.0 (/ Om Omc)) (hypot 1.0 (* (/ t l) (sqrt 2.0)))))))t = abs(t);
double code(double t, double l, double Om, double Omc) {
double tmp;
if (pow((t / l), 2.0) <= 5e+300) {
tmp = asin(sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l)))))));
} else {
tmp = asin((hypot(1.0, (Om / Omc)) / hypot(1.0, ((t / l) * sqrt(2.0)))));
}
return tmp;
}
t = Math.abs(t);
public static double code(double t, double l, double Om, double Omc) {
double tmp;
if (Math.pow((t / l), 2.0) <= 5e+300) {
tmp = Math.asin(Math.sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l)))))));
} else {
tmp = Math.asin((Math.hypot(1.0, (Om / Omc)) / Math.hypot(1.0, ((t / l) * Math.sqrt(2.0)))));
}
return tmp;
}
t = abs(t) def code(t, l, Om, Omc): tmp = 0 if math.pow((t / l), 2.0) <= 5e+300: tmp = math.asin(math.sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l))))))) else: tmp = math.asin((math.hypot(1.0, (Om / Omc)) / math.hypot(1.0, ((t / l) * math.sqrt(2.0))))) return tmp
t = abs(t) function code(t, l, Om, Omc) tmp = 0.0 if ((Float64(t / l) ^ 2.0) <= 5e+300) tmp = asin(sqrt(Float64(Float64(1.0 - Float64(Float64(Om / Omc) / Float64(Omc / Om))) / Float64(1.0 + Float64(2.0 * Float64(Float64(t / l) * Float64(t / l))))))); else tmp = asin(Float64(hypot(1.0, Float64(Om / Omc)) / hypot(1.0, Float64(Float64(t / l) * sqrt(2.0))))); end return tmp end
t = abs(t) function tmp_2 = code(t, l, Om, Omc) tmp = 0.0; if (((t / l) ^ 2.0) <= 5e+300) tmp = asin(sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l))))))); else tmp = asin((hypot(1.0, (Om / Omc)) / hypot(1.0, ((t / l) * sqrt(2.0))))); end tmp_2 = tmp; end
NOTE: t should be positive before calling this function code[t_, l_, Om_, Omc_] := If[LessEqual[N[Power[N[(t / l), $MachinePrecision], 2.0], $MachinePrecision], 5e+300], N[ArcSin[N[Sqrt[N[(N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] / N[(Omc / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(2.0 * N[(N[(t / l), $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[ArcSin[N[(N[Sqrt[1.0 ^ 2 + N[(Om / Omc), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[(t / l), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t = |t|\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{t}{\ell}\right)}^{2} \leq 5 \cdot 10^{+300}:\\
\;\;\;\;\sin^{-1} \left(\sqrt{\frac{1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}}{1 + 2 \cdot \left(\frac{t}{\ell} \cdot \frac{t}{\ell}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(\frac{\mathsf{hypot}\left(1, \frac{Om}{Omc}\right)}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 (/.f64 t l) 2) < 5.00000000000000026e300Initial program 98.8%
unpow298.8%
clear-num98.8%
frac-times93.9%
*-un-lft-identity93.9%
Applied egg-rr93.9%
unpow212.9%
clear-num12.9%
un-div-inv12.9%
Applied egg-rr93.9%
*-un-lft-identity93.9%
frac-times98.8%
clear-num98.8%
Applied egg-rr98.8%
if 5.00000000000000026e300 < (pow.f64 (/.f64 t l) 2) Initial program 47.3%
unpow247.3%
clear-num47.3%
clear-num47.3%
frac-times47.3%
metadata-eval47.3%
Applied egg-rr47.3%
unpow267.3%
clear-num67.3%
un-div-inv67.3%
Applied egg-rr47.3%
Applied egg-rr46.1%
expm1-def98.1%
expm1-log1p98.1%
Simplified98.1%
Final simplification98.6%
NOTE: t should be positive before calling this function (FPCore (t l Om Omc) :precision binary64 (asin (/ (sqrt (- 1.0 (/ (/ Om Omc) (/ Omc Om)))) (hypot 1.0 (* (/ t l) (sqrt 2.0))))))
t = abs(t);
double code(double t, double l, double Om, double Omc) {
return asin((sqrt((1.0 - ((Om / Omc) / (Omc / Om)))) / hypot(1.0, ((t / l) * sqrt(2.0)))));
}
t = Math.abs(t);
public static double code(double t, double l, double Om, double Omc) {
return Math.asin((Math.sqrt((1.0 - ((Om / Omc) / (Omc / Om)))) / Math.hypot(1.0, ((t / l) * Math.sqrt(2.0)))));
}
t = abs(t) def code(t, l, Om, Omc): return math.asin((math.sqrt((1.0 - ((Om / Omc) / (Omc / Om)))) / math.hypot(1.0, ((t / l) * math.sqrt(2.0)))))
t = abs(t) function code(t, l, Om, Omc) return asin(Float64(sqrt(Float64(1.0 - Float64(Float64(Om / Omc) / Float64(Omc / Om)))) / hypot(1.0, Float64(Float64(t / l) * sqrt(2.0))))) end
t = abs(t) function tmp = code(t, l, Om, Omc) tmp = asin((sqrt((1.0 - ((Om / Omc) / (Omc / Om)))) / hypot(1.0, ((t / l) * sqrt(2.0))))); end
NOTE: t should be positive before calling this function code[t_, l_, Om_, Omc_] := N[ArcSin[N[(N[Sqrt[N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] / N[(Omc / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[(t / l), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
t = |t|\\
\\
\sin^{-1} \left(\frac{\sqrt{1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}}}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\end{array}
Initial program 82.5%
sqrt-div82.5%
div-inv82.5%
add-sqr-sqrt82.5%
hypot-1-def82.5%
*-commutative82.5%
sqrt-prod82.4%
unpow282.4%
sqrt-prod54.1%
add-sqr-sqrt98.7%
Applied egg-rr98.7%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
unpow230.1%
clear-num30.1%
un-div-inv30.1%
Applied egg-rr98.7%
Final simplification98.7%
NOTE: t should be positive before calling this function
(FPCore (t l Om Omc)
:precision binary64
(let* ((t_1 (- 1.0 (/ (/ Om Omc) (/ Omc Om)))))
(if (<= (/ t l) -1e+161)
(asin (* (sqrt t_1) (/ (- l) (* t (sqrt 2.0)))))
(if (<= (/ t l) 40000000.0)
(asin (sqrt (/ t_1 (+ 1.0 (* 2.0 (* (/ t l) (/ t l)))))))
(asin
(*
(/ (* l (sqrt 0.5)) t)
(sqrt (- 1.0 (* (/ Om Omc) (/ Om Omc))))))))))t = abs(t);
double code(double t, double l, double Om, double Omc) {
double t_1 = 1.0 - ((Om / Omc) / (Omc / Om));
double tmp;
if ((t / l) <= -1e+161) {
tmp = asin((sqrt(t_1) * (-l / (t * sqrt(2.0)))));
} else if ((t / l) <= 40000000.0) {
tmp = asin(sqrt((t_1 / (1.0 + (2.0 * ((t / l) * (t / l)))))));
} else {
tmp = asin((((l * sqrt(0.5)) / t) * sqrt((1.0 - ((Om / Omc) * (Om / Omc))))));
}
return tmp;
}
NOTE: t should be positive before calling this function
real(8) function code(t, l, om, omc)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: omc
real(8) :: t_1
real(8) :: tmp
t_1 = 1.0d0 - ((om / omc) / (omc / om))
if ((t / l) <= (-1d+161)) then
tmp = asin((sqrt(t_1) * (-l / (t * sqrt(2.0d0)))))
else if ((t / l) <= 40000000.0d0) then
tmp = asin(sqrt((t_1 / (1.0d0 + (2.0d0 * ((t / l) * (t / l)))))))
else
tmp = asin((((l * sqrt(0.5d0)) / t) * sqrt((1.0d0 - ((om / omc) * (om / omc))))))
end if
code = tmp
end function
t = Math.abs(t);
public static double code(double t, double l, double Om, double Omc) {
double t_1 = 1.0 - ((Om / Omc) / (Omc / Om));
double tmp;
if ((t / l) <= -1e+161) {
tmp = Math.asin((Math.sqrt(t_1) * (-l / (t * Math.sqrt(2.0)))));
} else if ((t / l) <= 40000000.0) {
tmp = Math.asin(Math.sqrt((t_1 / (1.0 + (2.0 * ((t / l) * (t / l)))))));
} else {
tmp = Math.asin((((l * Math.sqrt(0.5)) / t) * Math.sqrt((1.0 - ((Om / Omc) * (Om / Omc))))));
}
return tmp;
}
t = abs(t) def code(t, l, Om, Omc): t_1 = 1.0 - ((Om / Omc) / (Omc / Om)) tmp = 0 if (t / l) <= -1e+161: tmp = math.asin((math.sqrt(t_1) * (-l / (t * math.sqrt(2.0))))) elif (t / l) <= 40000000.0: tmp = math.asin(math.sqrt((t_1 / (1.0 + (2.0 * ((t / l) * (t / l))))))) else: tmp = math.asin((((l * math.sqrt(0.5)) / t) * math.sqrt((1.0 - ((Om / Omc) * (Om / Omc)))))) return tmp
t = abs(t) function code(t, l, Om, Omc) t_1 = Float64(1.0 - Float64(Float64(Om / Omc) / Float64(Omc / Om))) tmp = 0.0 if (Float64(t / l) <= -1e+161) tmp = asin(Float64(sqrt(t_1) * Float64(Float64(-l) / Float64(t * sqrt(2.0))))); elseif (Float64(t / l) <= 40000000.0) tmp = asin(sqrt(Float64(t_1 / Float64(1.0 + Float64(2.0 * Float64(Float64(t / l) * Float64(t / l))))))); else tmp = asin(Float64(Float64(Float64(l * sqrt(0.5)) / t) * sqrt(Float64(1.0 - Float64(Float64(Om / Omc) * Float64(Om / Omc)))))); end return tmp end
t = abs(t) function tmp_2 = code(t, l, Om, Omc) t_1 = 1.0 - ((Om / Omc) / (Omc / Om)); tmp = 0.0; if ((t / l) <= -1e+161) tmp = asin((sqrt(t_1) * (-l / (t * sqrt(2.0))))); elseif ((t / l) <= 40000000.0) tmp = asin(sqrt((t_1 / (1.0 + (2.0 * ((t / l) * (t / l))))))); else tmp = asin((((l * sqrt(0.5)) / t) * sqrt((1.0 - ((Om / Omc) * (Om / Omc)))))); end tmp_2 = tmp; end
NOTE: t should be positive before calling this function
code[t_, l_, Om_, Omc_] := Block[{t$95$1 = N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] / N[(Omc / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t / l), $MachinePrecision], -1e+161], N[ArcSin[N[(N[Sqrt[t$95$1], $MachinePrecision] * N[((-l) / N[(t * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(t / l), $MachinePrecision], 40000000.0], N[ArcSin[N[Sqrt[N[(t$95$1 / N[(1.0 + N[(2.0 * N[(N[(t / l), $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[ArcSin[N[(N[(N[(l * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] * N[Sqrt[N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] * N[(Om / Omc), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
t = |t|\\
\\
\begin{array}{l}
t_1 := 1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}\\
\mathbf{if}\;\frac{t}{\ell} \leq -1 \cdot 10^{+161}:\\
\;\;\;\;\sin^{-1} \left(\sqrt{t_1} \cdot \frac{-\ell}{t \cdot \sqrt{2}}\right)\\
\mathbf{elif}\;\frac{t}{\ell} \leq 40000000:\\
\;\;\;\;\sin^{-1} \left(\sqrt{\frac{t_1}{1 + 2 \cdot \left(\frac{t}{\ell} \cdot \frac{t}{\ell}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(\frac{\ell \cdot \sqrt{0.5}}{t} \cdot \sqrt{1 - \frac{Om}{Omc} \cdot \frac{Om}{Omc}}\right)\\
\end{array}
\end{array}
if (/.f64 t l) < -1e161Initial program 50.6%
sqrt-div50.6%
div-inv50.6%
add-sqr-sqrt50.6%
hypot-1-def50.6%
*-commutative50.6%
sqrt-prod50.6%
unpow250.6%
sqrt-prod0.0%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in t around -inf 91.3%
mul-1-neg91.3%
*-commutative91.3%
distribute-rgt-neg-in91.3%
unpow291.3%
unpow291.3%
times-frac99.6%
unpow299.6%
Simplified99.6%
unpow299.6%
clear-num99.6%
un-div-inv99.6%
Applied egg-rr99.6%
if -1e161 < (/.f64 t l) < 4e7Initial program 98.6%
unpow298.6%
clear-num98.6%
frac-times96.1%
*-un-lft-identity96.1%
Applied egg-rr96.1%
unpow214.8%
clear-num14.8%
un-div-inv14.8%
Applied egg-rr96.1%
*-un-lft-identity96.1%
frac-times98.6%
clear-num98.6%
Applied egg-rr98.6%
if 4e7 < (/.f64 t l) Initial program 65.2%
Taylor expanded in t around inf 85.7%
unpow285.7%
unpow285.7%
frac-times99.5%
Applied egg-rr99.5%
Final simplification99.0%
NOTE: t should be positive before calling this function
(FPCore (t l Om Omc)
:precision binary64
(if (<= (/ t l) 40000000.0)
(asin
(sqrt
(/
(- 1.0 (/ (/ Om Omc) (/ Omc Om)))
(+ 1.0 (* 2.0 (* (/ t l) (/ t l)))))))
(asin (* (/ (* l (sqrt 0.5)) t) (sqrt (- 1.0 (* (/ Om Omc) (/ Om Omc))))))))t = abs(t);
double code(double t, double l, double Om, double Omc) {
double tmp;
if ((t / l) <= 40000000.0) {
tmp = asin(sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l)))))));
} else {
tmp = asin((((l * sqrt(0.5)) / t) * sqrt((1.0 - ((Om / Omc) * (Om / Omc))))));
}
return tmp;
}
NOTE: t should be positive before calling this function
real(8) function code(t, l, om, omc)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: omc
real(8) :: tmp
if ((t / l) <= 40000000.0d0) then
tmp = asin(sqrt(((1.0d0 - ((om / omc) / (omc / om))) / (1.0d0 + (2.0d0 * ((t / l) * (t / l)))))))
else
tmp = asin((((l * sqrt(0.5d0)) / t) * sqrt((1.0d0 - ((om / omc) * (om / omc))))))
end if
code = tmp
end function
t = Math.abs(t);
public static double code(double t, double l, double Om, double Omc) {
double tmp;
if ((t / l) <= 40000000.0) {
tmp = Math.asin(Math.sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l)))))));
} else {
tmp = Math.asin((((l * Math.sqrt(0.5)) / t) * Math.sqrt((1.0 - ((Om / Omc) * (Om / Omc))))));
}
return tmp;
}
t = abs(t) def code(t, l, Om, Omc): tmp = 0 if (t / l) <= 40000000.0: tmp = math.asin(math.sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l))))))) else: tmp = math.asin((((l * math.sqrt(0.5)) / t) * math.sqrt((1.0 - ((Om / Omc) * (Om / Omc)))))) return tmp
t = abs(t) function code(t, l, Om, Omc) tmp = 0.0 if (Float64(t / l) <= 40000000.0) tmp = asin(sqrt(Float64(Float64(1.0 - Float64(Float64(Om / Omc) / Float64(Omc / Om))) / Float64(1.0 + Float64(2.0 * Float64(Float64(t / l) * Float64(t / l))))))); else tmp = asin(Float64(Float64(Float64(l * sqrt(0.5)) / t) * sqrt(Float64(1.0 - Float64(Float64(Om / Omc) * Float64(Om / Omc)))))); end return tmp end
t = abs(t) function tmp_2 = code(t, l, Om, Omc) tmp = 0.0; if ((t / l) <= 40000000.0) tmp = asin(sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l))))))); else tmp = asin((((l * sqrt(0.5)) / t) * sqrt((1.0 - ((Om / Omc) * (Om / Omc)))))); end tmp_2 = tmp; end
NOTE: t should be positive before calling this function code[t_, l_, Om_, Omc_] := If[LessEqual[N[(t / l), $MachinePrecision], 40000000.0], N[ArcSin[N[Sqrt[N[(N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] / N[(Omc / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(2.0 * N[(N[(t / l), $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[ArcSin[N[(N[(N[(l * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] * N[Sqrt[N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] * N[(Om / Omc), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t = |t|\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{t}{\ell} \leq 40000000:\\
\;\;\;\;\sin^{-1} \left(\sqrt{\frac{1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}}{1 + 2 \cdot \left(\frac{t}{\ell} \cdot \frac{t}{\ell}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(\frac{\ell \cdot \sqrt{0.5}}{t} \cdot \sqrt{1 - \frac{Om}{Omc} \cdot \frac{Om}{Omc}}\right)\\
\end{array}
\end{array}
if (/.f64 t l) < 4e7Initial program 89.2%
unpow289.2%
clear-num89.2%
frac-times87.2%
*-un-lft-identity87.2%
Applied egg-rr87.2%
unpow231.4%
clear-num31.4%
un-div-inv31.4%
Applied egg-rr87.2%
*-un-lft-identity87.2%
frac-times89.2%
clear-num89.2%
Applied egg-rr89.2%
if 4e7 < (/.f64 t l) Initial program 65.2%
Taylor expanded in t around inf 85.7%
unpow285.7%
unpow285.7%
frac-times99.5%
Applied egg-rr99.5%
Final simplification92.1%
NOTE: t should be positive before calling this function (FPCore (t l Om Omc) :precision binary64 (asin (sqrt (/ (- 1.0 (/ (/ Om Omc) (/ Omc Om))) (+ 1.0 (* 2.0 (* (/ t l) (/ t l))))))))
t = abs(t);
double code(double t, double l, double Om, double Omc) {
return asin(sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l)))))));
}
NOTE: t should be positive before calling this function
real(8) function code(t, l, om, omc)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: omc
code = asin(sqrt(((1.0d0 - ((om / omc) / (omc / om))) / (1.0d0 + (2.0d0 * ((t / l) * (t / l)))))))
end function
t = Math.abs(t);
public static double code(double t, double l, double Om, double Omc) {
return Math.asin(Math.sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l)))))));
}
t = abs(t) def code(t, l, Om, Omc): return math.asin(math.sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l)))))))
t = abs(t) function code(t, l, Om, Omc) return asin(sqrt(Float64(Float64(1.0 - Float64(Float64(Om / Omc) / Float64(Omc / Om))) / Float64(1.0 + Float64(2.0 * Float64(Float64(t / l) * Float64(t / l))))))) end
t = abs(t) function tmp = code(t, l, Om, Omc) tmp = asin(sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l))))))); end
NOTE: t should be positive before calling this function code[t_, l_, Om_, Omc_] := N[ArcSin[N[Sqrt[N[(N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] / N[(Omc / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(2.0 * N[(N[(t / l), $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
t = |t|\\
\\
\sin^{-1} \left(\sqrt{\frac{1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}}{1 + 2 \cdot \left(\frac{t}{\ell} \cdot \frac{t}{\ell}\right)}}\right)
\end{array}
Initial program 82.5%
unpow282.5%
clear-num82.5%
frac-times79.1%
*-un-lft-identity79.1%
Applied egg-rr79.1%
unpow230.1%
clear-num30.1%
un-div-inv30.1%
Applied egg-rr79.1%
*-un-lft-identity79.1%
frac-times82.5%
clear-num82.5%
Applied egg-rr82.5%
Final simplification82.5%
NOTE: t should be positive before calling this function (FPCore (t l Om Omc) :precision binary64 (asin (sqrt (- 1.0 (/ (/ Om Omc) (/ Omc Om))))))
t = abs(t);
double code(double t, double l, double Om, double Omc) {
return asin(sqrt((1.0 - ((Om / Omc) / (Omc / Om)))));
}
NOTE: t should be positive before calling this function
real(8) function code(t, l, om, omc)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: omc
code = asin(sqrt((1.0d0 - ((om / omc) / (omc / om)))))
end function
t = Math.abs(t);
public static double code(double t, double l, double Om, double Omc) {
return Math.asin(Math.sqrt((1.0 - ((Om / Omc) / (Omc / Om)))));
}
t = abs(t) def code(t, l, Om, Omc): return math.asin(math.sqrt((1.0 - ((Om / Omc) / (Omc / Om)))))
t = abs(t) function code(t, l, Om, Omc) return asin(sqrt(Float64(1.0 - Float64(Float64(Om / Omc) / Float64(Omc / Om))))) end
t = abs(t) function tmp = code(t, l, Om, Omc) tmp = asin(sqrt((1.0 - ((Om / Omc) / (Omc / Om))))); end
NOTE: t should be positive before calling this function code[t_, l_, Om_, Omc_] := N[ArcSin[N[Sqrt[N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] / N[(Omc / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
t = |t|\\
\\
\sin^{-1} \left(\sqrt{1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}}\right)
\end{array}
Initial program 82.5%
Taylor expanded in t around 0 43.6%
unpow243.6%
unpow243.6%
times-frac48.9%
unpow248.9%
Simplified48.9%
unpow230.1%
clear-num30.1%
un-div-inv30.1%
Applied egg-rr48.9%
Final simplification48.9%
herbie shell --seed 2023306
(FPCore (t l Om Omc)
:name "Toniolo and Linder, Equation (2)"
:precision binary64
(asin (sqrt (/ (- 1.0 (pow (/ Om Omc) 2.0)) (+ 1.0 (* 2.0 (pow (/ t l) 2.0)))))))