Average Error: 10.4 → 0.7
Time: 12.2s
Precision: binary64
\[\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{1 + 2 \cdot {\left(\frac{t}{\ell}\right)}^{2}}}\right) \]
\[\begin{array}{l} t_1 := \frac{\ell \cdot \sqrt{0.5}}{t}\\ t_2 := 1 - {\left(\frac{Om}{Omc}\right)}^{2}\\ t_3 := \sqrt{t_2}\\ \mathbf{if}\;\frac{t}{\ell} \leq -2.2117319219733597 \cdot 10^{+154}:\\ \;\;\;\;\sin^{-1} \left(t_3 \cdot \left(-t_1\right)\right)\\ \mathbf{elif}\;\frac{t}{\ell} \leq 1.2864542022364115 \cdot 10^{+109}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\sin^{-1} \left(\sqrt{\frac{t_2}{\mathsf{fma}\left(2, {\left(\frac{t}{\ell}\right)}^{2}, 1\right)}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin^{-1} \left(t_3 \cdot t_1\right)\\ \end{array} \]
\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{1 + 2 \cdot {\left(\frac{t}{\ell}\right)}^{2}}}\right)
\begin{array}{l}
t_1 := \frac{\ell \cdot \sqrt{0.5}}{t}\\
t_2 := 1 - {\left(\frac{Om}{Omc}\right)}^{2}\\
t_3 := \sqrt{t_2}\\
\mathbf{if}\;\frac{t}{\ell} \leq -2.2117319219733597 \cdot 10^{+154}:\\
\;\;\;\;\sin^{-1} \left(t_3 \cdot \left(-t_1\right)\right)\\

\mathbf{elif}\;\frac{t}{\ell} \leq 1.2864542022364115 \cdot 10^{+109}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\sin^{-1} \left(\sqrt{\frac{t_2}{\mathsf{fma}\left(2, {\left(\frac{t}{\ell}\right)}^{2}, 1\right)}}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(t_3 \cdot t_1\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)))))))
(FPCore (t l Om Omc)
 :precision binary64
 (let* ((t_1 (/ (* l (sqrt 0.5)) t))
        (t_2 (- 1.0 (pow (/ Om Omc) 2.0)))
        (t_3 (sqrt t_2)))
   (if (<= (/ t l) -2.2117319219733597e+154)
     (asin (* t_3 (- t_1)))
     (if (<= (/ t l) 1.2864542022364115e+109)
       (expm1 (log1p (asin (sqrt (/ t_2 (fma 2.0 (pow (/ t l) 2.0) 1.0))))))
       (asin (* t_3 t_1))))))
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)))));
}
double code(double t, double l, double Om, double Omc) {
	double t_1 = (l * sqrt(0.5)) / t;
	double t_2 = 1.0 - pow((Om / Omc), 2.0);
	double t_3 = sqrt(t_2);
	double tmp;
	if ((t / l) <= -2.2117319219733597e+154) {
		tmp = asin(t_3 * -t_1);
	} else if ((t / l) <= 1.2864542022364115e+109) {
		tmp = expm1(log1p(asin(sqrt(t_2 / fma(2.0, pow((t / l), 2.0), 1.0)))));
	} else {
		tmp = asin(t_3 * t_1);
	}
	return tmp;
}

Error

Bits error versus t

Bits error versus l

Bits error versus Om

Bits error versus Omc

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 t l) < -2.21173192197335974e154

    1. Initial program 33.3

      \[\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{1 + 2 \cdot {\left(\frac{t}{\ell}\right)}^{2}}}\right) \]
    2. Simplified33.3

      \[\leadsto \color{blue}{\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{\mathsf{fma}\left(2, {\left(\frac{t}{\ell}\right)}^{2}, 1\right)}}\right)} \]
    3. Taylor expanded in t around -inf 8.3

      \[\leadsto \sin^{-1} \color{blue}{\left(-1 \cdot \left(\frac{\sqrt{0.5} \cdot \ell}{t} \cdot \sqrt{1 - \frac{{Om}^{2}}{{Omc}^{2}}}\right)\right)} \]
    4. Simplified0.2

      \[\leadsto \sin^{-1} \color{blue}{\left(\sqrt{1 - {\left(\frac{Om}{Omc}\right)}^{2}} \cdot \left(-\frac{\ell \cdot \sqrt{0.5}}{t}\right)\right)} \]

    if -2.21173192197335974e154 < (/.f64 t l) < 1.2864542022364115e109

    1. Initial program 0.9

      \[\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{1 + 2 \cdot {\left(\frac{t}{\ell}\right)}^{2}}}\right) \]
    2. Simplified0.9

      \[\leadsto \color{blue}{\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{\mathsf{fma}\left(2, {\left(\frac{t}{\ell}\right)}^{2}, 1\right)}}\right)} \]
    3. Applied expm1-log1p-u_binary640.9

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{\mathsf{fma}\left(2, {\left(\frac{t}{\ell}\right)}^{2}, 1\right)}}\right)\right)\right)} \]

    if 1.2864542022364115e109 < (/.f64 t l)

    1. Initial program 30.2

      \[\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{1 + 2 \cdot {\left(\frac{t}{\ell}\right)}^{2}}}\right) \]
    2. Simplified30.2

      \[\leadsto \color{blue}{\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{\mathsf{fma}\left(2, {\left(\frac{t}{\ell}\right)}^{2}, 1\right)}}\right)} \]
    3. Taylor expanded in t around inf 7.0

      \[\leadsto \sin^{-1} \color{blue}{\left(\frac{\sqrt{0.5} \cdot \ell}{t} \cdot \sqrt{1 - \frac{{Om}^{2}}{{Omc}^{2}}}\right)} \]
    4. Simplified0.3

      \[\leadsto \sin^{-1} \color{blue}{\left(\sqrt{1 - {\left(\frac{Om}{Omc}\right)}^{2}} \cdot \frac{\ell \cdot \sqrt{0.5}}{t}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{t}{\ell} \leq -2.2117319219733597 \cdot 10^{+154}:\\ \;\;\;\;\sin^{-1} \left(\sqrt{1 - {\left(\frac{Om}{Omc}\right)}^{2}} \cdot \left(-\frac{\ell \cdot \sqrt{0.5}}{t}\right)\right)\\ \mathbf{elif}\;\frac{t}{\ell} \leq 1.2864542022364115 \cdot 10^{+109}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{\mathsf{fma}\left(2, {\left(\frac{t}{\ell}\right)}^{2}, 1\right)}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin^{-1} \left(\sqrt{1 - {\left(\frac{Om}{Omc}\right)}^{2}} \cdot \frac{\ell \cdot \sqrt{0.5}}{t}\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022067 
(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)))))))