Average Error: 1.1 → 0.6
Time: 11.1s
Precision: binary64
\[[kx, ky]=\mathsf{sort}([kx, ky])\]
\[\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 := {\left(\frac{2 \cdot \ell}{Om}\right)}^{2}\\ \mathbf{if}\;t_0 \leq 1.0718034203244173 \cdot 10^{+245}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{\mathsf{fma}\left(t_0, {\sin kx}^{2} + {\sin ky}^{2}, 1\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{fma}\left(2, \frac{\ell \cdot \sin ky}{Om}, 0.25 \cdot \frac{Om}{\ell \cdot ky}\right)}}\\ \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 := {\left(\frac{2 \cdot \ell}{Om}\right)}^{2}\\
\mathbf{if}\;t_0 \leq 1.0718034203244173 \cdot 10^{+245}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{\mathsf{fma}\left(t_0, {\sin kx}^{2} + {\sin ky}^{2}, 1\right)}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{fma}\left(2, \frac{\ell \cdot \sin ky}{Om}, 0.25 \cdot \frac{Om}{\ell \cdot ky}\right)}}\\


\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 (/ (* 2.0 l) Om) 2.0)))
   (if (<= t_0 1.0718034203244173e+245)
     (sqrt
      (+
       0.5
       (/ 0.5 (sqrt (fma t_0 (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)) 1.0)))))
     (sqrt
      (+
       0.5
       (/ 0.5 (fma 2.0 (/ (* l (sin ky)) Om) (* 0.25 (/ Om (* l ky))))))))))
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(((2.0 * l) / Om), 2.0);
	double tmp;
	if (t_0 <= 1.0718034203244173e+245) {
		tmp = sqrt(0.5 + (0.5 / sqrt(fma(t_0, (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)), 1.0))));
	} else {
		tmp = sqrt(0.5 + (0.5 / fma(2.0, ((l * sin(ky)) / Om), (0.25 * (Om / (l * ky))))));
	}
	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) < 1.07180342032441729e245

    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)}}}} \]

    if 1.07180342032441729e245 < (pow.f64 (/.f64 (*.f64 2 l) Om) 2)

    1. Initial program 3.5

      \[\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.5

      \[\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 in Om around 0 15.2

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

      \[\leadsto \sqrt{0.5 + \frac{0.5}{\color{blue}{\mathsf{fma}\left(0.5, Om \cdot \sqrt{\frac{0.25}{\left(\ell \cdot \ell\right) \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}, \frac{\sqrt{4 \cdot \left(\left(\ell \cdot \ell\right) \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)\right)}}{Om}\right)}}} \]
    5. Taylor expanded in kx around 0 1.7

      \[\leadsto \sqrt{0.5 + \color{blue}{\frac{0.5}{0.25 \cdot \frac{Om}{\ell \cdot \sin ky} + 2 \cdot \frac{\ell \cdot \sin ky}{Om}}}} \]
    6. Simplified1.7

      \[\leadsto \sqrt{0.5 + \color{blue}{\frac{0.5}{\mathsf{fma}\left(2, \frac{\sin ky \cdot \ell}{Om}, 0.25 \cdot \frac{Om}{\sin ky \cdot \ell}\right)}}} \]
    7. Taylor expanded in ky around 0 1.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \leq 1.0718034203244173 \cdot 10^{+245}:\\ \;\;\;\;\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)}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{fma}\left(2, \frac{\ell \cdot \sin ky}{Om}, 0.25 \cdot \frac{Om}{\ell \cdot ky}\right)}}\\ \end{array} \]

Reproduce

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