Average Error: 1.0 → 0.3
Time: 9.0s
Precision: binary64
\[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
\[\begin{array}{l} t_0 := {\sin kx}^{2}\\ t_1 := {\sin ky}^{2}\\ t_2 := {\left(\frac{2 \cdot \ell}{Om}\right)}^{2}\\ \mathbf{if}\;t_2 \leq 3.033132613028815 \cdot 10^{+261}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt[3]{{\left(\mathsf{fma}\left(t_2, t_0 + t_1, 1\right)\right)}^{1.5}}}}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := \frac{4}{Om} \cdot \left(\frac{t_1}{Om} + \frac{t_0}{Om}\right)\\ \sqrt{0.5 + \frac{0.5}{\mathsf{fma}\left(\ell, \sqrt{t_3}, 0.5 \cdot \frac{{t_3}^{-0.5}}{\ell}\right)}} \end{array}\\ \end{array} \]
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\begin{array}{l}
t_0 := {\sin kx}^{2}\\
t_1 := {\sin ky}^{2}\\
t_2 := {\left(\frac{2 \cdot \ell}{Om}\right)}^{2}\\
\mathbf{if}\;t_2 \leq 3.033132613028815 \cdot 10^{+261}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt[3]{{\left(\mathsf{fma}\left(t_2, t_0 + t_1, 1\right)\right)}^{1.5}}}}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \frac{4}{Om} \cdot \left(\frac{t_1}{Om} + \frac{t_0}{Om}\right)\\
\sqrt{0.5 + \frac{0.5}{\mathsf{fma}\left(\ell, \sqrt{t_3}, 0.5 \cdot \frac{{t_3}^{-0.5}}{\ell}\right)}}
\end{array}\\


\end{array}
(FPCore (l Om kx ky)
 :precision binary64
 (sqrt
  (*
   (/ 1.0 2.0)
   (+
    1.0
    (/
     1.0
     (sqrt
      (+
       1.0
       (*
        (pow (/ (* 2.0 l) Om) 2.0)
        (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
(FPCore (l Om kx ky)
 :precision binary64
 (let* ((t_0 (pow (sin kx) 2.0))
        (t_1 (pow (sin ky) 2.0))
        (t_2 (pow (/ (* 2.0 l) Om) 2.0)))
   (if (<= t_2 3.033132613028815e+261)
     (sqrt (+ 0.5 (/ 0.5 (cbrt (pow (fma t_2 (+ t_0 t_1) 1.0) 1.5)))))
     (let* ((t_3 (* (/ 4.0 Om) (+ (/ t_1 Om) (/ t_0 Om)))))
       (sqrt
        (+ 0.5 (/ 0.5 (fma l (sqrt t_3) (* 0.5 (/ (pow t_3 -0.5) l))))))))))
double code(double l, double Om, double kx, double ky) {
	return sqrt((1.0 / 2.0) * (1.0 + (1.0 / sqrt(1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))));
}
double code(double l, double Om, double kx, double ky) {
	double t_0 = pow(sin(kx), 2.0);
	double t_1 = pow(sin(ky), 2.0);
	double t_2 = pow(((2.0 * l) / Om), 2.0);
	double tmp;
	if (t_2 <= 3.033132613028815e+261) {
		tmp = sqrt(0.5 + (0.5 / cbrt(pow(fma(t_2, (t_0 + t_1), 1.0), 1.5))));
	} else {
		double t_3 = (4.0 / Om) * ((t_1 / Om) + (t_0 / Om));
		tmp = sqrt(0.5 + (0.5 / fma(l, sqrt(t_3), (0.5 * (pow(t_3, -0.5) / l)))));
	}
	return tmp;
}

Error

Bits error versus l

Bits error versus Om

Bits error versus kx

Bits error versus ky

Derivation

  1. Split input into 2 regimes
  2. if (pow.f64 (/.f64 (*.f64 2 l) Om) 2) < 3.03313261302881495e261

    1. Initial program 0.0

      \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
    2. Simplified0.0

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{0.5}{\sqrt{\mathsf{fma}\left({\left(\frac{2 \cdot \ell}{Om}\right)}^{2}, {\sin kx}^{2} + {\sin ky}^{2}, 1\right)}}}} \]
    3. Using strategy rm
    4. Applied add-cbrt-cube_binary640.0

      \[\leadsto \sqrt{0.5 + \frac{0.5}{\color{blue}{\sqrt[3]{\left(\sqrt{\mathsf{fma}\left({\left(\frac{2 \cdot \ell}{Om}\right)}^{2}, {\sin kx}^{2} + {\sin ky}^{2}, 1\right)} \cdot \sqrt{\mathsf{fma}\left({\left(\frac{2 \cdot \ell}{Om}\right)}^{2}, {\sin kx}^{2} + {\sin ky}^{2}, 1\right)}\right) \cdot \sqrt{\mathsf{fma}\left({\left(\frac{2 \cdot \ell}{Om}\right)}^{2}, {\sin kx}^{2} + {\sin ky}^{2}, 1\right)}}}}} \]
    5. Simplified0.0

      \[\leadsto \sqrt{0.5 + \frac{0.5}{\sqrt[3]{\color{blue}{{\left(\mathsf{fma}\left({\left(\frac{2 \cdot \ell}{Om}\right)}^{2}, {\sin kx}^{2} + {\sin ky}^{2}, 1\right)\right)}^{1.5}}}}} \]

    if 3.03313261302881495e261 < (pow.f64 (/.f64 (*.f64 2 l) Om) 2)

    1. Initial program 3.4

      \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
    2. Simplified3.4

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{0.5}{\sqrt{\mathsf{fma}\left({\left(\frac{2 \cdot \ell}{Om}\right)}^{2}, {\sin kx}^{2} + {\sin ky}^{2}, 1\right)}}}} \]
    3. Taylor expanded around inf 14.5

      \[\leadsto \sqrt{0.5 + \frac{0.5}{\color{blue}{0.5 \cdot \left(\frac{1}{\ell} \cdot \sqrt{\frac{1}{4 \cdot \frac{{\sin ky}^{2}}{{Om}^{2}} + 4 \cdot \frac{{\sin kx}^{2}}{{Om}^{2}}}}\right) + \ell \cdot \sqrt{4 \cdot \frac{{\sin ky}^{2}}{{Om}^{2}} + 4 \cdot \frac{{\sin kx}^{2}}{{Om}^{2}}}}}} \]
    4. Simplified0.9

      \[\leadsto \sqrt{0.5 + \frac{0.5}{\color{blue}{\mathsf{fma}\left(\ell, \sqrt{\frac{4}{Om} \cdot \left(\frac{{\sin ky}^{2}}{Om} + \frac{{\sin kx}^{2}}{Om}\right)}, 0.5 \cdot \frac{\sqrt{\frac{1}{\frac{4}{Om} \cdot \left(\frac{{\sin ky}^{2}}{Om} + \frac{{\sin kx}^{2}}{Om}\right)}}}{\ell}\right)}}} \]
    5. Using strategy rm
    6. Applied inv-pow_binary640.9

      \[\leadsto \sqrt{0.5 + \frac{0.5}{\mathsf{fma}\left(\ell, \sqrt{\frac{4}{Om} \cdot \left(\frac{{\sin ky}^{2}}{Om} + \frac{{\sin kx}^{2}}{Om}\right)}, 0.5 \cdot \frac{\sqrt{\color{blue}{{\left(\frac{4}{Om} \cdot \left(\frac{{\sin ky}^{2}}{Om} + \frac{{\sin kx}^{2}}{Om}\right)\right)}^{-1}}}}{\ell}\right)}} \]
    7. Applied sqrt-pow1_binary640.9

      \[\leadsto \sqrt{0.5 + \frac{0.5}{\mathsf{fma}\left(\ell, \sqrt{\frac{4}{Om} \cdot \left(\frac{{\sin ky}^{2}}{Om} + \frac{{\sin kx}^{2}}{Om}\right)}, 0.5 \cdot \frac{\color{blue}{{\left(\frac{4}{Om} \cdot \left(\frac{{\sin ky}^{2}}{Om} + \frac{{\sin kx}^{2}}{Om}\right)\right)}^{\left(\frac{-1}{2}\right)}}}{\ell}\right)}} \]
    8. Simplified0.9

      \[\leadsto \sqrt{0.5 + \frac{0.5}{\mathsf{fma}\left(\ell, \sqrt{\frac{4}{Om} \cdot \left(\frac{{\sin ky}^{2}}{Om} + \frac{{\sin kx}^{2}}{Om}\right)}, 0.5 \cdot \frac{{\left(\frac{4}{Om} \cdot \left(\frac{{\sin ky}^{2}}{Om} + \frac{{\sin kx}^{2}}{Om}\right)\right)}^{\color{blue}{-0.5}}}{\ell}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \leq 3.033132613028815 \cdot 10^{+261}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt[3]{{\left(\mathsf{fma}\left({\left(\frac{2 \cdot \ell}{Om}\right)}^{2}, {\sin kx}^{2} + {\sin ky}^{2}, 1\right)\right)}^{1.5}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{fma}\left(\ell, \sqrt{\frac{4}{Om} \cdot \left(\frac{{\sin ky}^{2}}{Om} + \frac{{\sin kx}^{2}}{Om}\right)}, 0.5 \cdot \frac{{\left(\frac{4}{Om} \cdot \left(\frac{{\sin ky}^{2}}{Om} + \frac{{\sin kx}^{2}}{Om}\right)\right)}^{-0.5}}{\ell}\right)}}\\ \end{array} \]

Reproduce

herbie shell --seed 2021211 
(FPCore (l Om kx ky)
  :name "Toniolo and Linder, Equation (3a)"
  :precision binary64
  (sqrt (* (/ 1.0 2.0) (+ 1.0 (/ 1.0 (sqrt (+ 1.0 (* (pow (/ (* 2.0 l) Om) 2.0) (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))