
(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}
(FPCore (t l Om Omc) :precision binary64 (asin (/ (sqrt (- 1.0 (/ (/ Om Omc) (/ Omc Om)))) (hypot 1.0 (/ (* (sqrt 2.0) t) l)))))
double code(double t, double l, double Om, double Omc) {
return asin((sqrt((1.0 - ((Om / Omc) / (Omc / Om)))) / hypot(1.0, ((sqrt(2.0) * t) / l))));
}
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, ((Math.sqrt(2.0) * t) / l))));
}
def code(t, l, Om, Omc): return math.asin((math.sqrt((1.0 - ((Om / Omc) / (Omc / Om)))) / math.hypot(1.0, ((math.sqrt(2.0) * t) / l))))
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(sqrt(2.0) * t) / l)))) end
function tmp = code(t, l, Om, Omc) tmp = asin((sqrt((1.0 - ((Om / Omc) / (Omc / Om)))) / hypot(1.0, ((sqrt(2.0) * t) / l)))); end
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[(N[Sqrt[2.0], $MachinePrecision] * t), $MachinePrecision] / l), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} \left(\frac{\sqrt{1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}}}{\mathsf{hypot}\left(1, \frac{\sqrt{2} \cdot t}{\ell}\right)}\right)
\end{array}
Initial program 85.9%
sqrt-div85.9%
div-inv85.9%
add-sqr-sqrt85.9%
hypot-1-def85.9%
*-commutative85.9%
sqrt-prod85.9%
sqrt-pow198.5%
metadata-eval98.5%
pow198.5%
Applied egg-rr98.5%
associate-*r/98.5%
*-rgt-identity98.5%
*-commutative98.5%
associate-*r/98.5%
Simplified98.5%
unpow298.5%
clear-num98.5%
un-div-inv98.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (t l Om Omc) :precision binary64 (asin (/ 1.0 (hypot 1.0 (* (sqrt 2.0) (/ t l))))))
double code(double t, double l, double Om, double Omc) {
return asin((1.0 / hypot(1.0, (sqrt(2.0) * (t / l)))));
}
public static double code(double t, double l, double Om, double Omc) {
return Math.asin((1.0 / Math.hypot(1.0, (Math.sqrt(2.0) * (t / l)))));
}
def code(t, l, Om, Omc): return math.asin((1.0 / math.hypot(1.0, (math.sqrt(2.0) * (t / l)))))
function code(t, l, Om, Omc) return asin(Float64(1.0 / hypot(1.0, Float64(sqrt(2.0) * Float64(t / l))))) end
function tmp = code(t, l, Om, Omc) tmp = asin((1.0 / hypot(1.0, (sqrt(2.0) * (t / l))))); end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Sqrt[2.0], $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} \left(\frac{1}{\mathsf{hypot}\left(1, \sqrt{2} \cdot \frac{t}{\ell}\right)}\right)
\end{array}
Initial program 85.9%
sqrt-div85.9%
div-inv85.9%
add-sqr-sqrt85.9%
hypot-1-def85.9%
*-commutative85.9%
sqrt-prod85.9%
sqrt-pow198.5%
metadata-eval98.5%
pow198.5%
Applied egg-rr98.5%
associate-*r/98.5%
*-rgt-identity98.5%
*-commutative98.5%
associate-*r/98.5%
Simplified98.5%
Taylor expanded in Om around 0 97.4%
associate-/l*97.4%
pow197.4%
metadata-eval97.4%
sqrt-pow185.0%
sqrt-prod85.0%
*-commutative85.0%
sqrt-prod85.0%
sqrt-pow197.4%
metadata-eval97.4%
pow197.4%
Applied egg-rr97.4%
Final simplification97.4%
(FPCore (t l Om Omc) :precision binary64 (asin (/ 1.0 (hypot 1.0 (/ (* (sqrt 2.0) t) l)))))
double code(double t, double l, double Om, double Omc) {
return asin((1.0 / hypot(1.0, ((sqrt(2.0) * t) / l))));
}
public static double code(double t, double l, double Om, double Omc) {
return Math.asin((1.0 / Math.hypot(1.0, ((Math.sqrt(2.0) * t) / l))));
}
def code(t, l, Om, Omc): return math.asin((1.0 / math.hypot(1.0, ((math.sqrt(2.0) * t) / l))))
function code(t, l, Om, Omc) return asin(Float64(1.0 / hypot(1.0, Float64(Float64(sqrt(2.0) * t) / l)))) end
function tmp = code(t, l, Om, Omc) tmp = asin((1.0 / hypot(1.0, ((sqrt(2.0) * t) / l)))); end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(N[Sqrt[2.0], $MachinePrecision] * t), $MachinePrecision] / l), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} \left(\frac{1}{\mathsf{hypot}\left(1, \frac{\sqrt{2} \cdot t}{\ell}\right)}\right)
\end{array}
Initial program 85.9%
sqrt-div85.9%
div-inv85.9%
add-sqr-sqrt85.9%
hypot-1-def85.9%
*-commutative85.9%
sqrt-prod85.9%
sqrt-pow198.5%
metadata-eval98.5%
pow198.5%
Applied egg-rr98.5%
associate-*r/98.5%
*-rgt-identity98.5%
*-commutative98.5%
associate-*r/98.5%
Simplified98.5%
Taylor expanded in Om around 0 97.4%
Final simplification97.4%
(FPCore (t l Om Omc) :precision binary64 (asin (/ 1.0 (hypot 1.0 (* t (/ (sqrt 2.0) l))))))
double code(double t, double l, double Om, double Omc) {
return asin((1.0 / hypot(1.0, (t * (sqrt(2.0) / l)))));
}
public static double code(double t, double l, double Om, double Omc) {
return Math.asin((1.0 / Math.hypot(1.0, (t * (Math.sqrt(2.0) / l)))));
}
def code(t, l, Om, Omc): return math.asin((1.0 / math.hypot(1.0, (t * (math.sqrt(2.0) / l)))))
function code(t, l, Om, Omc) return asin(Float64(1.0 / hypot(1.0, Float64(t * Float64(sqrt(2.0) / l))))) end
function tmp = code(t, l, Om, Omc) tmp = asin((1.0 / hypot(1.0, (t * (sqrt(2.0) / l))))); end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(t * N[(N[Sqrt[2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} \left(\frac{1}{\mathsf{hypot}\left(1, t \cdot \frac{\sqrt{2}}{\ell}\right)}\right)
\end{array}
Initial program 85.9%
sqrt-div85.9%
div-inv85.9%
add-sqr-sqrt85.9%
hypot-1-def85.9%
*-commutative85.9%
sqrt-prod85.9%
sqrt-pow198.5%
metadata-eval98.5%
pow198.5%
Applied egg-rr98.5%
associate-*r/98.5%
*-rgt-identity98.5%
*-commutative98.5%
associate-*r/98.5%
Simplified98.5%
Taylor expanded in Om around 0 97.4%
*-commutative97.4%
*-un-lft-identity97.4%
times-frac97.4%
Applied egg-rr97.4%
Final simplification97.4%
(FPCore (t l Om Omc) :precision binary64 (if (<= t 8.5e+96) (asin (sqrt (- 1.0 (/ (/ Om Omc) (/ Omc Om))))) (asin (/ l (* (sqrt 2.0) t)))))
double code(double t, double l, double Om, double Omc) {
double tmp;
if (t <= 8.5e+96) {
tmp = asin(sqrt((1.0 - ((Om / Omc) / (Omc / Om)))));
} else {
tmp = asin((l / (sqrt(2.0) * t)));
}
return tmp;
}
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 <= 8.5d+96) then
tmp = asin(sqrt((1.0d0 - ((om / omc) / (omc / om)))))
else
tmp = asin((l / (sqrt(2.0d0) * t)))
end if
code = tmp
end function
public static double code(double t, double l, double Om, double Omc) {
double tmp;
if (t <= 8.5e+96) {
tmp = Math.asin(Math.sqrt((1.0 - ((Om / Omc) / (Omc / Om)))));
} else {
tmp = Math.asin((l / (Math.sqrt(2.0) * t)));
}
return tmp;
}
def code(t, l, Om, Omc): tmp = 0 if t <= 8.5e+96: tmp = math.asin(math.sqrt((1.0 - ((Om / Omc) / (Omc / Om))))) else: tmp = math.asin((l / (math.sqrt(2.0) * t))) return tmp
function code(t, l, Om, Omc) tmp = 0.0 if (t <= 8.5e+96) tmp = asin(sqrt(Float64(1.0 - Float64(Float64(Om / Omc) / Float64(Omc / Om))))); else tmp = asin(Float64(l / Float64(sqrt(2.0) * t))); end return tmp end
function tmp_2 = code(t, l, Om, Omc) tmp = 0.0; if (t <= 8.5e+96) tmp = asin(sqrt((1.0 - ((Om / Omc) / (Omc / Om))))); else tmp = asin((l / (sqrt(2.0) * t))); end tmp_2 = tmp; end
code[t_, l_, Om_, Omc_] := If[LessEqual[t, 8.5e+96], N[ArcSin[N[Sqrt[N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] / N[(Omc / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[ArcSin[N[(l / N[(N[Sqrt[2.0], $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 8.5 \cdot 10^{+96}:\\
\;\;\;\;\sin^{-1} \left(\sqrt{1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(\frac{\ell}{\sqrt{2} \cdot t}\right)\\
\end{array}
\end{array}
if t < 8.50000000000000025e96Initial program 88.5%
Taylor expanded in t around 0 53.4%
unpow253.4%
unpow253.4%
times-frac60.1%
unpow260.1%
Simplified60.1%
unpow298.6%
clear-num98.6%
un-div-inv98.6%
Applied egg-rr60.1%
if 8.50000000000000025e96 < t Initial program 76.8%
sqrt-div76.8%
div-inv76.8%
add-sqr-sqrt76.8%
hypot-1-def76.8%
*-commutative76.8%
sqrt-prod76.6%
sqrt-pow198.1%
metadata-eval98.1%
pow198.1%
Applied egg-rr98.1%
associate-*r/98.1%
*-rgt-identity98.1%
*-commutative98.1%
associate-*r/98.2%
Simplified98.2%
Taylor expanded in Om around 0 98.2%
Taylor expanded in t around inf 53.1%
Final simplification58.6%
(FPCore (t l Om Omc) :precision binary64 (if (<= t 1.4e+95) (asin 1.0) (asin (/ l (* (sqrt 2.0) t)))))
double code(double t, double l, double Om, double Omc) {
double tmp;
if (t <= 1.4e+95) {
tmp = asin(1.0);
} else {
tmp = asin((l / (sqrt(2.0) * t)));
}
return tmp;
}
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 <= 1.4d+95) then
tmp = asin(1.0d0)
else
tmp = asin((l / (sqrt(2.0d0) * t)))
end if
code = tmp
end function
public static double code(double t, double l, double Om, double Omc) {
double tmp;
if (t <= 1.4e+95) {
tmp = Math.asin(1.0);
} else {
tmp = Math.asin((l / (Math.sqrt(2.0) * t)));
}
return tmp;
}
def code(t, l, Om, Omc): tmp = 0 if t <= 1.4e+95: tmp = math.asin(1.0) else: tmp = math.asin((l / (math.sqrt(2.0) * t))) return tmp
function code(t, l, Om, Omc) tmp = 0.0 if (t <= 1.4e+95) tmp = asin(1.0); else tmp = asin(Float64(l / Float64(sqrt(2.0) * t))); end return tmp end
function tmp_2 = code(t, l, Om, Omc) tmp = 0.0; if (t <= 1.4e+95) tmp = asin(1.0); else tmp = asin((l / (sqrt(2.0) * t))); end tmp_2 = tmp; end
code[t_, l_, Om_, Omc_] := If[LessEqual[t, 1.4e+95], N[ArcSin[1.0], $MachinePrecision], N[ArcSin[N[(l / N[(N[Sqrt[2.0], $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.4 \cdot 10^{+95}:\\
\;\;\;\;\sin^{-1} 1\\
\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(\frac{\ell}{\sqrt{2} \cdot t}\right)\\
\end{array}
\end{array}
if t < 1.3999999999999999e95Initial program 88.5%
Taylor expanded in t around 0 53.4%
unpow253.4%
unpow253.4%
times-frac60.1%
unpow260.1%
Simplified60.1%
Taylor expanded in Om around 0 59.4%
if 1.3999999999999999e95 < t Initial program 76.8%
sqrt-div76.8%
div-inv76.8%
add-sqr-sqrt76.8%
hypot-1-def76.8%
*-commutative76.8%
sqrt-prod76.6%
sqrt-pow198.1%
metadata-eval98.1%
pow198.1%
Applied egg-rr98.1%
associate-*r/98.1%
*-rgt-identity98.1%
*-commutative98.1%
associate-*r/98.2%
Simplified98.2%
Taylor expanded in Om around 0 98.2%
Taylor expanded in t around inf 53.1%
Final simplification58.0%
(FPCore (t l Om Omc) :precision binary64 (asin 1.0))
double code(double t, double l, double Om, double Omc) {
return asin(1.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(1.0d0)
end function
public static double code(double t, double l, double Om, double Omc) {
return Math.asin(1.0);
}
def code(t, l, Om, Omc): return math.asin(1.0)
function code(t, l, Om, Omc) return asin(1.0) end
function tmp = code(t, l, Om, Omc) tmp = asin(1.0); end
code[t_, l_, Om_, Omc_] := N[ArcSin[1.0], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} 1
\end{array}
Initial program 85.9%
Taylor expanded in t around 0 47.4%
unpow247.4%
unpow247.4%
times-frac53.2%
unpow253.2%
Simplified53.2%
Taylor expanded in Om around 0 52.6%
Final simplification52.6%
herbie shell --seed 2024077
(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)))))))