Average Error: 10.4 → 1.7
Time: 14.6s
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 := 1 - {\left(\frac{Om}{Omc}\right)}^{2}\\ t_2 := \sqrt{t_1}\\ \mathbf{if}\;\frac{t}{\ell} \leq -1.8210917523283662 \cdot 10^{+180}:\\ \;\;\;\;\sin^{-1} \left(\frac{t_2}{-\frac{t \cdot \sqrt{2}}{\ell}}\right)\\ \mathbf{elif}\;\frac{t}{\ell} \leq 1.7392727750868362 \cdot 10^{+112}:\\ \;\;\;\;\sin^{-1} \left(\sqrt{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{t_1}{\mathsf{fma}\left(2, {\left(\frac{t}{\ell}\right)}^{2}, 1\right)}\right)\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin^{-1} \left(t_2 \cdot \frac{\ell \cdot \sqrt{0.5}}{t}\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 := 1 - {\left(\frac{Om}{Omc}\right)}^{2}\\
t_2 := \sqrt{t_1}\\
\mathbf{if}\;\frac{t}{\ell} \leq -1.8210917523283662 \cdot 10^{+180}:\\
\;\;\;\;\sin^{-1} \left(\frac{t_2}{-\frac{t \cdot \sqrt{2}}{\ell}}\right)\\

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

\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(t_2 \cdot \frac{\ell \cdot \sqrt{0.5}}{t}\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 (- 1.0 (pow (/ Om Omc) 2.0))) (t_2 (sqrt t_1)))
   (if (<= (/ t l) -1.8210917523283662e+180)
     (asin (/ t_2 (- (/ (* t (sqrt 2.0)) l))))
     (if (<= (/ t l) 1.7392727750868362e+112)
       (asin (sqrt (log1p (expm1 (/ t_1 (fma 2.0 (pow (/ t l) 2.0) 1.0))))))
       (asin (* t_2 (/ (* l (sqrt 0.5)) t)))))))
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 = 1.0 - pow((Om / Omc), 2.0);
	double t_2 = sqrt(t_1);
	double tmp;
	if ((t / l) <= -1.8210917523283662e+180) {
		tmp = asin(t_2 / -((t * sqrt(2.0)) / l));
	} else if ((t / l) <= 1.7392727750868362e+112) {
		tmp = asin(sqrt(log1p(expm1(t_1 / fma(2.0, pow((t / l), 2.0), 1.0)))));
	} else {
		tmp = asin(t_2 * ((l * sqrt(0.5)) / t));
	}
	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) < -1.8210917523283662e180

    1. Initial program 30.1

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

      \[\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 sqrt-div_binary6430.1

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

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

    if -1.8210917523283662e180 < (/.f64 t l) < 1.73927277508683619e112

    1. Initial program 2.1

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

      \[\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 log1p-expm1-u_binary642.1

      \[\leadsto \sin^{-1} \left(\sqrt{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\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.73927277508683619e112 < (/.f64 t l)

    1. Initial program 29.3

      \[\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{1 + 2 \cdot {\left(\frac{t}{\ell}\right)}^{2}}}\right) \]
    2. Simplified29.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 9.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 simplification1.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{t}{\ell} \leq -1.8210917523283662 \cdot 10^{+180}:\\ \;\;\;\;\sin^{-1} \left(\frac{\sqrt{1 - {\left(\frac{Om}{Omc}\right)}^{2}}}{-\frac{t \cdot \sqrt{2}}{\ell}}\right)\\ \mathbf{elif}\;\frac{t}{\ell} \leq 1.7392727750868362 \cdot 10^{+112}:\\ \;\;\;\;\sin^{-1} \left(\sqrt{\mathsf{log1p}\left(\mathsf{expm1}\left(\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 2022087 
(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)))))))