
(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 5 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)) (+ 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}
Initial program 82.3%
(FPCore (t l Om Omc) :precision binary64 (asin (/ (- 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(((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(((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(((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(((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(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(((1.0 - ((Om / Omc) ^ 2.0)) / (1.0 + (2.0 * ((t / l) ^ 2.0))))); end
code[t_, l_, Om_, Omc_] := N[ArcSin[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]
\begin{array}{l}
\\
\sin^{-1} \left(\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{1 + 2 \cdot {\left(\frac{t}{\ell}\right)}^{2}}\right)
\end{array}
Initial program 82.3%
Taylor expanded in t around 0
Applied rewrites61.6%
(FPCore (t l Om Omc) :precision binary64 (let* ((t_1 (pow (/ Om Omc) 2.0))) (if (<= (pow (/ t l) 2.0) 4e+224) (asin (- 1.0 t_1)) (asin t_1))))
double code(double t, double l, double Om, double Omc) {
double t_1 = pow((Om / Omc), 2.0);
double tmp;
if (pow((t / l), 2.0) <= 4e+224) {
tmp = asin((1.0 - t_1));
} else {
tmp = asin(t_1);
}
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 = (om / omc) ** 2.0d0
if (((t / l) ** 2.0d0) <= 4d+224) then
tmp = asin((1.0d0 - t_1))
else
tmp = asin(t_1)
end if
code = tmp
end function
public static double code(double t, double l, double Om, double Omc) {
double t_1 = Math.pow((Om / Omc), 2.0);
double tmp;
if (Math.pow((t / l), 2.0) <= 4e+224) {
tmp = Math.asin((1.0 - t_1));
} else {
tmp = Math.asin(t_1);
}
return tmp;
}
def code(t, l, Om, Omc): t_1 = math.pow((Om / Omc), 2.0) tmp = 0 if math.pow((t / l), 2.0) <= 4e+224: tmp = math.asin((1.0 - t_1)) else: tmp = math.asin(t_1) return tmp
function code(t, l, Om, Omc) t_1 = Float64(Om / Omc) ^ 2.0 tmp = 0.0 if ((Float64(t / l) ^ 2.0) <= 4e+224) tmp = asin(Float64(1.0 - t_1)); else tmp = asin(t_1); end return tmp end
function tmp_2 = code(t, l, Om, Omc) t_1 = (Om / Omc) ^ 2.0; tmp = 0.0; if (((t / l) ^ 2.0) <= 4e+224) tmp = asin((1.0 - t_1)); else tmp = asin(t_1); end tmp_2 = tmp; end
code[t_, l_, Om_, Omc_] := Block[{t$95$1 = N[Power[N[(Om / Omc), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[Power[N[(t / l), $MachinePrecision], 2.0], $MachinePrecision], 4e+224], N[ArcSin[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision], N[ArcSin[t$95$1], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\left(\frac{Om}{Omc}\right)}^{2}\\
\mathbf{if}\;{\left(\frac{t}{\ell}\right)}^{2} \leq 4 \cdot 10^{+224}:\\
\;\;\;\;\sin^{-1} \left(1 - t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\sin^{-1} t\_1\\
\end{array}
\end{array}
if (pow.f64 (/.f64 t l) #s(literal 2 binary64)) < 3.99999999999999988e224Initial program 98.9%
Taylor expanded in t around 0
Applied rewrites73.8%
if 3.99999999999999988e224 < (pow.f64 (/.f64 t l) #s(literal 2 binary64)) Initial program 49.5%
Taylor expanded in t around 0
Applied rewrites24.4%
(FPCore (t l Om Omc) :precision binary64 (asin (pow (/ Om Omc) 2.0)))
double code(double t, double l, double Om, double Omc) {
return asin(pow((Om / Omc), 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(((om / omc) ** 2.0d0))
end function
public static double code(double t, double l, double Om, double Omc) {
return Math.asin(Math.pow((Om / Omc), 2.0));
}
def code(t, l, Om, Omc): return math.asin(math.pow((Om / Omc), 2.0))
function code(t, l, Om, Omc) return asin((Float64(Om / Omc) ^ 2.0)) end
function tmp = code(t, l, Om, Omc) tmp = asin(((Om / Omc) ^ 2.0)); end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[Power[N[(Om / Omc), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} \left({\left(\frac{Om}{Omc}\right)}^{2}\right)
\end{array}
Initial program 82.3%
Taylor expanded in t around 0
Applied rewrites11.1%
(FPCore (t l Om Omc) :precision binary64 (asin (/ Om Omc)))
double code(double t, double l, double Om, double Omc) {
return asin((Om / Omc));
}
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((om / omc))
end function
public static double code(double t, double l, double Om, double Omc) {
return Math.asin((Om / Omc));
}
def code(t, l, Om, Omc): return math.asin((Om / Omc))
function code(t, l, Om, Omc) return asin(Float64(Om / Omc)) end
function tmp = code(t, l, Om, Omc) tmp = asin((Om / Omc)); end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[(Om / Omc), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} \left(\frac{Om}{Omc}\right)
\end{array}
Initial program 82.3%
Taylor expanded in t around 0
Applied rewrites50.3%
Taylor expanded in t around inf
Applied rewrites6.9%
herbie shell --seed 2024321
(FPCore (t l Om Omc)
:name "Toniolo and Linder, Equation (2)"
:precision binary64
:pre (TRUE)
(asin (sqrt (/ (- 1.0 (pow (/ Om Omc) 2.0)) (+ 1.0 (* 2.0 (pow (/ t l) 2.0)))))))