
(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 6 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 (pow (/ Om Omc) 2.0))) (hypot 1.0 (* (/ t l) (sqrt 2.0))))))
double code(double t, double l, double Om, double Omc) {
return asin((sqrt((1.0 - pow((Om / Omc), 2.0))) / hypot(1.0, ((t / l) * sqrt(2.0)))));
}
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))) / Math.hypot(1.0, ((t / l) * Math.sqrt(2.0)))));
}
def code(t, l, Om, Omc): return math.asin((math.sqrt((1.0 - math.pow((Om / Omc), 2.0))) / math.hypot(1.0, ((t / l) * math.sqrt(2.0)))))
function code(t, l, Om, Omc) return asin(Float64(sqrt(Float64(1.0 - (Float64(Om / Omc) ^ 2.0))) / hypot(1.0, Float64(Float64(t / l) * sqrt(2.0))))) end
function tmp = code(t, l, Om, Omc) tmp = asin((sqrt((1.0 - ((Om / Omc) ^ 2.0))) / hypot(1.0, ((t / l) * sqrt(2.0))))); end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[(N[Sqrt[N[(1.0 - N[Power[N[(Om / Omc), $MachinePrecision], 2.0], $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}
\\
\sin^{-1} \left(\frac{\sqrt{1 - {\left(\frac{Om}{Omc}\right)}^{2}}}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\end{array}
Initial program 83.7%
sqrt-div83.7%
add-sqr-sqrt83.7%
hypot-1-def83.7%
*-commutative83.7%
sqrt-prod83.7%
sqrt-pow199.2%
metadata-eval99.2%
pow199.2%
Applied egg-rr99.2%
(FPCore (t l Om Omc) :precision binary64 (asin (/ (sqrt (- 1.0 (/ (/ Om Omc) (/ Omc Om)))) (hypot 1.0 (/ (* t (sqrt 2.0)) l)))))
double code(double t, double l, double Om, double Omc) {
return asin((sqrt((1.0 - ((Om / Omc) / (Omc / Om)))) / hypot(1.0, ((t * sqrt(2.0)) / 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, ((t * Math.sqrt(2.0)) / l))));
}
def code(t, l, Om, Omc): return math.asin((math.sqrt((1.0 - ((Om / Omc) / (Omc / Om)))) / math.hypot(1.0, ((t * math.sqrt(2.0)) / 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(t * sqrt(2.0)) / l)))) end
function tmp = code(t, l, Om, Omc) tmp = asin((sqrt((1.0 - ((Om / Omc) / (Omc / Om)))) / hypot(1.0, ((t * sqrt(2.0)) / 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[(t * N[Sqrt[2.0], $MachinePrecision]), $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{t \cdot \sqrt{2}}{\ell}\right)}\right)
\end{array}
Initial program 83.7%
sqrt-div83.7%
div-inv83.7%
add-sqr-sqrt83.7%
hypot-1-def83.7%
*-commutative83.7%
sqrt-prod83.7%
sqrt-pow199.2%
metadata-eval99.2%
pow199.2%
Applied egg-rr99.2%
associate-*r/99.2%
*-rgt-identity99.2%
*-commutative99.2%
associate-*r/98.8%
Simplified98.8%
unpow298.8%
clear-num98.8%
un-div-inv98.8%
Applied egg-rr98.8%
Final simplification98.8%
(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 83.7%
add-exp-log82.4%
+-commutative82.4%
fma-define82.4%
Applied egg-rr82.4%
Taylor expanded in Om around 0 66.5%
+-commutative66.5%
fma-define66.5%
unpow266.5%
unpow266.5%
times-frac82.0%
unpow282.0%
Simplified82.0%
sqrt-div82.0%
metadata-eval82.0%
Applied egg-rr82.0%
unpow282.0%
times-frac66.5%
unpow266.5%
unpow266.5%
fma-define66.5%
+-commutative66.5%
metadata-eval66.5%
rem-square-sqrt66.5%
unpow266.5%
unpow266.5%
times-frac82.0%
swap-sqr82.0%
hypot-undefine95.9%
Simplified95.9%
*-un-lft-identity95.9%
rem-exp-log98.6%
associate-*r/98.3%
Applied egg-rr98.3%
*-lft-identity98.3%
*-commutative98.3%
associate-/l*98.6%
Simplified98.6%
(FPCore (t l Om Omc)
:precision binary64
(let* ((t_1 (asin (sqrt (- 1.0 (/ (/ Om Omc) (/ Omc Om)))))))
(if (<= t 3.8e-55)
t_1
(if (<= t 2.9e-22)
(asin (/ l (/ t (sqrt 0.5))))
(if (<= t 7e+83) t_1 (asin (* (/ 1.0 t) (* l (sqrt 0.5)))))))))
double code(double t, double l, double Om, double Omc) {
double t_1 = asin(sqrt((1.0 - ((Om / Omc) / (Omc / Om)))));
double tmp;
if (t <= 3.8e-55) {
tmp = t_1;
} else if (t <= 2.9e-22) {
tmp = asin((l / (t / sqrt(0.5))));
} else if (t <= 7e+83) {
tmp = t_1;
} else {
tmp = asin(((1.0 / t) * (l * sqrt(0.5))));
}
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) :: t_1
real(8) :: tmp
t_1 = asin(sqrt((1.0d0 - ((om / omc) / (omc / om)))))
if (t <= 3.8d-55) then
tmp = t_1
else if (t <= 2.9d-22) then
tmp = asin((l / (t / sqrt(0.5d0))))
else if (t <= 7d+83) then
tmp = t_1
else
tmp = asin(((1.0d0 / t) * (l * sqrt(0.5d0))))
end if
code = tmp
end function
public static double code(double t, double l, double Om, double Omc) {
double t_1 = Math.asin(Math.sqrt((1.0 - ((Om / Omc) / (Omc / Om)))));
double tmp;
if (t <= 3.8e-55) {
tmp = t_1;
} else if (t <= 2.9e-22) {
tmp = Math.asin((l / (t / Math.sqrt(0.5))));
} else if (t <= 7e+83) {
tmp = t_1;
} else {
tmp = Math.asin(((1.0 / t) * (l * Math.sqrt(0.5))));
}
return tmp;
}
def code(t, l, Om, Omc): t_1 = math.asin(math.sqrt((1.0 - ((Om / Omc) / (Omc / Om))))) tmp = 0 if t <= 3.8e-55: tmp = t_1 elif t <= 2.9e-22: tmp = math.asin((l / (t / math.sqrt(0.5)))) elif t <= 7e+83: tmp = t_1 else: tmp = math.asin(((1.0 / t) * (l * math.sqrt(0.5)))) return tmp
function code(t, l, Om, Omc) t_1 = asin(sqrt(Float64(1.0 - Float64(Float64(Om / Omc) / Float64(Omc / Om))))) tmp = 0.0 if (t <= 3.8e-55) tmp = t_1; elseif (t <= 2.9e-22) tmp = asin(Float64(l / Float64(t / sqrt(0.5)))); elseif (t <= 7e+83) tmp = t_1; else tmp = asin(Float64(Float64(1.0 / t) * Float64(l * sqrt(0.5)))); end return tmp end
function tmp_2 = code(t, l, Om, Omc) t_1 = asin(sqrt((1.0 - ((Om / Omc) / (Omc / Om))))); tmp = 0.0; if (t <= 3.8e-55) tmp = t_1; elseif (t <= 2.9e-22) tmp = asin((l / (t / sqrt(0.5)))); elseif (t <= 7e+83) tmp = t_1; else tmp = asin(((1.0 / t) * (l * sqrt(0.5)))); end tmp_2 = tmp; end
code[t_, l_, Om_, Omc_] := Block[{t$95$1 = N[ArcSin[N[Sqrt[N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] / N[(Omc / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, 3.8e-55], t$95$1, If[LessEqual[t, 2.9e-22], N[ArcSin[N[(l / N[(t / N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 7e+83], t$95$1, N[ArcSin[N[(N[(1.0 / t), $MachinePrecision] * N[(l * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin^{-1} \left(\sqrt{1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}}\right)\\
\mathbf{if}\;t \leq 3.8 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.9 \cdot 10^{-22}:\\
\;\;\;\;\sin^{-1} \left(\frac{\ell}{\frac{t}{\sqrt{0.5}}}\right)\\
\mathbf{elif}\;t \leq 7 \cdot 10^{+83}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(\frac{1}{t} \cdot \left(\ell \cdot \sqrt{0.5}\right)\right)\\
\end{array}
\end{array}
if t < 3.7999999999999997e-55 or 2.9000000000000002e-22 < t < 6.99999999999999954e83Initial program 87.7%
Taylor expanded in t around 0 55.7%
unpow255.7%
unpow255.7%
times-frac61.7%
unpow261.7%
Simplified61.7%
unpow299.1%
clear-num99.1%
un-div-inv99.1%
Applied egg-rr61.7%
if 3.7999999999999997e-55 < t < 2.9000000000000002e-22Initial program 52.8%
Taylor expanded in t around inf 50.5%
*-commutative50.5%
unpow250.5%
unpow250.5%
times-frac50.5%
unpow250.5%
associate-/l*50.2%
Simplified50.2%
unpow299.3%
clear-num99.3%
un-div-inv99.3%
Applied egg-rr50.2%
Taylor expanded in Om around 0 50.5%
associate-/l*50.2%
Simplified50.2%
clear-num50.2%
un-div-inv50.5%
Applied egg-rr50.5%
if 6.99999999999999954e83 < t Initial program 72.4%
Taylor expanded in t around inf 58.5%
*-commutative58.5%
unpow258.5%
unpow258.5%
times-frac60.8%
unpow260.8%
associate-/l*60.9%
Simplified60.9%
unpow297.3%
clear-num97.3%
un-div-inv97.3%
Applied egg-rr60.9%
Taylor expanded in Om around 0 60.8%
associate-/l*60.9%
Simplified60.9%
associate-*r/60.8%
clear-num60.7%
Applied egg-rr60.7%
associate-/r/60.9%
Simplified60.9%
(FPCore (t l Om Omc) :precision binary64 (asin (* (/ 1.0 t) (* l (sqrt 0.5)))))
double code(double t, double l, double Om, double Omc) {
return asin(((1.0 / t) * (l * sqrt(0.5))));
}
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 / t) * (l * sqrt(0.5d0))))
end function
public static double code(double t, double l, double Om, double Omc) {
return Math.asin(((1.0 / t) * (l * Math.sqrt(0.5))));
}
def code(t, l, Om, Omc): return math.asin(((1.0 / t) * (l * math.sqrt(0.5))))
function code(t, l, Om, Omc) return asin(Float64(Float64(1.0 / t) * Float64(l * sqrt(0.5)))) end
function tmp = code(t, l, Om, Omc) tmp = asin(((1.0 / t) * (l * sqrt(0.5)))); end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[(N[(1.0 / t), $MachinePrecision] * N[(l * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} \left(\frac{1}{t} \cdot \left(\ell \cdot \sqrt{0.5}\right)\right)
\end{array}
Initial program 83.7%
Taylor expanded in t around inf 32.3%
*-commutative32.3%
unpow232.3%
unpow232.3%
times-frac33.9%
unpow233.9%
associate-/l*33.9%
Simplified33.9%
unpow298.8%
clear-num98.8%
un-div-inv98.8%
Applied egg-rr33.9%
Taylor expanded in Om around 0 33.9%
associate-/l*33.9%
Simplified33.9%
associate-*r/33.9%
clear-num33.8%
Applied egg-rr33.8%
associate-/r/33.9%
Simplified33.9%
(FPCore (t l Om Omc) :precision binary64 (asin (* l (/ (sqrt 0.5) t))))
double code(double t, double l, double Om, double Omc) {
return asin((l * (sqrt(0.5) / t)));
}
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((l * (sqrt(0.5d0) / t)))
end function
public static double code(double t, double l, double Om, double Omc) {
return Math.asin((l * (Math.sqrt(0.5) / t)));
}
def code(t, l, Om, Omc): return math.asin((l * (math.sqrt(0.5) / t)))
function code(t, l, Om, Omc) return asin(Float64(l * Float64(sqrt(0.5) / t))) end
function tmp = code(t, l, Om, Omc) tmp = asin((l * (sqrt(0.5) / t))); end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[(l * N[(N[Sqrt[0.5], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} \left(\ell \cdot \frac{\sqrt{0.5}}{t}\right)
\end{array}
Initial program 83.7%
Taylor expanded in t around inf 32.3%
*-commutative32.3%
unpow232.3%
unpow232.3%
times-frac33.9%
unpow233.9%
associate-/l*33.9%
Simplified33.9%
unpow298.8%
clear-num98.8%
un-div-inv98.8%
Applied egg-rr33.9%
Taylor expanded in Om around 0 33.9%
associate-/l*33.9%
Simplified33.9%
herbie shell --seed 2024088
(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)))))))