Average Error: 0.9 → 0.4
Time: 8.6s
Precision: binary64
\[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}\right)}}\right)}\]
\[\begin{array}{l} \mathbf{if}\;{\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \leq 2.3603258989887747 \cdot 10^{+218}:\\ \;\;\;\;\sqrt{0.5 + \log \left(e^{\frac{0.5}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}\right)}}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array}\]
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}\right)}}\right)}
\begin{array}{l}
\mathbf{if}\;{\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \leq 2.3603258989887747 \cdot 10^{+218}:\\
\;\;\;\;\sqrt{0.5 + \log \left(e^{\frac{0.5}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}\right)}}}\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\

\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
 (if (<= (pow (/ (* 2.0 l) Om) 2.0) 2.3603258989887747e+218)
   (sqrt
    (+
     0.5
     (log
      (exp
       (/
        0.5
        (sqrt
         (+
          1.0
          (*
           (pow (/ (* 2.0 l) Om) 2.0)
           (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
   (sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
	return ((double) sqrt(((double) ((1.0 / 2.0) * ((double) (1.0 + (1.0 / ((double) sqrt(((double) (1.0 + ((double) (((double) pow((((double) (2.0 * l)) / Om), 2.0)) * ((double) (((double) pow(((double) sin(kx)), 2.0)) + ((double) pow(((double) sin(ky)), 2.0)))))))))))))))));
}
double code(double l, double Om, double kx, double ky) {
	double tmp;
	if ((((double) pow((((double) (2.0 * l)) / Om), 2.0)) <= 2.3603258989887747e+218)) {
		tmp = ((double) sqrt(((double) (0.5 + ((double) log(((double) exp((0.5 / ((double) sqrt(((double) (1.0 + ((double) (((double) pow((((double) (2.0 * l)) / Om), 2.0)) * ((double) (((double) pow(((double) sin(kx)), 2.0)) + ((double) pow(((double) sin(ky)), 2.0)))))))))))))))))));
	} else {
		tmp = ((double) sqrt(0.5));
	}
	return tmp;
}

Error

Bits error versus l

Bits error versus Om

Bits error versus kx

Bits error versus ky

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

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

    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({\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}\right)}}\right)}\]
    2. Simplified0.0

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

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

    if 2.3603258989887747e218 < (pow.f64 (/.f64 (*.f64 2 l) Om) 2)

    1. Initial program 2.8

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

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

      \[\leadsto \sqrt{0.5 + \color{blue}{0}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \leq 2.3603258989887747 \cdot 10^{+218}:\\ \;\;\;\;\sqrt{0.5 + \log \left(e^{\frac{0.5}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}\right)}}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array}\]

Reproduce

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