Toniolo and Linder, Equation (3a)

Percentage Accurate: 98.3% → 100.0%
Time: 16.4s
Alternatives: 8
Speedup: 1.4×

Specification

?
\[\begin{array}{l} \\ \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)} \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))))))))))
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)))))))));
}
real(8) function code(l, om, kx, ky)
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
	return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky):
	return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky)
	return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))))))))
end
function tmp = code(l, Om, kx, ky)
	tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))))))));
end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\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)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 98.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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)} \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))))))))))
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)))))))));
}
real(8) function code(l, om, kx, ky)
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
	return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky):
	return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky)
	return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))))))))
end
function tmp = code(l, Om, kx, ky)
	tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))))))));
end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\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)}
\end{array}

Alternative 1: 100.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (sqrt
  (+
   0.5
   (*
    0.5
    (/ 1.0 (hypot 1.0 (* (hypot (sin ky) (sin kx)) (* l (/ 2.0 Om)))))))))
double code(double l, double Om, double kx, double ky) {
	return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (hypot(sin(ky), sin(kx)) * (l * (2.0 / Om))))))));
}
public static double code(double l, double Om, double kx, double ky) {
	return Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, (Math.hypot(Math.sin(ky), Math.sin(kx)) * (l * (2.0 / Om))))))));
}
def code(l, Om, kx, ky):
	return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (math.hypot(math.sin(ky), math.sin(kx)) * (l * (2.0 / Om))))))))
function code(l, Om, kx, ky)
	return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(hypot(sin(ky), sin(kx)) * Float64(l * Float64(2.0 / Om))))))))
end
function tmp = code(l, Om, kx, ky)
	tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (hypot(sin(ky), sin(kx)) * (l * (2.0 / Om))))))));
end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}
\end{array}
Derivation
  1. Initial program 98.8%

    \[\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. Step-by-step derivation
    1. distribute-rgt-in98.8%

      \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
    2. metadata-eval98.8%

      \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
    3. metadata-eval98.8%

      \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
    4. associate-/l*98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
    5. metadata-eval98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \color{blue}{0.5}} \]
  3. Simplified98.8%

    \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
  4. Step-by-step derivation
    1. expm1-log1p-u98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
    2. expm1-udef98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
  5. Applied egg-rr100.0%

    \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
  6. Step-by-step derivation
    1. expm1-def100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
    2. expm1-log1p100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
    3. *-commutative100.0%

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

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    5. unpow298.9%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    6. unpow298.9%

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

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

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    9. unpow298.9%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    10. hypot-def100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    11. *-commutative100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
    12. associate-*l/100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
    13. associate-*r/100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
  7. Simplified100.0%

    \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
  8. Final simplification100.0%

    \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \]

Alternative 2: 98.0% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin ky}^{2} \leq 0.022:\\ \;\;\;\;\sqrt{0.5 + 0.5 \cdot {\left(1 + {\left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}^{2}\right)}^{-0.5}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(\sin ky \cdot \ell\right)\right)}}\\ \end{array} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (if (<= (pow (sin ky) 2.0) 0.022)
   (sqrt
    (+ 0.5 (* 0.5 (pow (+ 1.0 (pow (* (sin kx) (* l (/ 2.0 Om))) 2.0)) -0.5))))
   (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ 2.0 Om) (* (sin ky) l))))))))
double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (pow(sin(ky), 2.0) <= 0.022) {
		tmp = sqrt((0.5 + (0.5 * pow((1.0 + pow((sin(kx) * (l * (2.0 / Om))), 2.0)), -0.5))));
	} else {
		tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l))))));
	}
	return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (Math.pow(Math.sin(ky), 2.0) <= 0.022) {
		tmp = Math.sqrt((0.5 + (0.5 * Math.pow((1.0 + Math.pow((Math.sin(kx) * (l * (2.0 / Om))), 2.0)), -0.5))));
	} else {
		tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 / Om) * (Math.sin(ky) * l))))));
	}
	return tmp;
}
def code(l, Om, kx, ky):
	tmp = 0
	if math.pow(math.sin(ky), 2.0) <= 0.022:
		tmp = math.sqrt((0.5 + (0.5 * math.pow((1.0 + math.pow((math.sin(kx) * (l * (2.0 / Om))), 2.0)), -0.5))))
	else:
		tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 / Om) * (math.sin(ky) * l))))))
	return tmp
function code(l, Om, kx, ky)
	tmp = 0.0
	if ((sin(ky) ^ 2.0) <= 0.022)
		tmp = sqrt(Float64(0.5 + Float64(0.5 * (Float64(1.0 + (Float64(sin(kx) * Float64(l * Float64(2.0 / Om))) ^ 2.0)) ^ -0.5))));
	else
		tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 / Om) * Float64(sin(ky) * l))))));
	end
	return tmp
end
function tmp_2 = code(l, Om, kx, ky)
	tmp = 0.0;
	if ((sin(ky) ^ 2.0) <= 0.022)
		tmp = sqrt((0.5 + (0.5 * ((1.0 + ((sin(kx) * (l * (2.0 / Om))) ^ 2.0)) ^ -0.5))));
	else
		tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l))))));
	end
	tmp_2 = tmp;
end
code[l_, Om_, kx_, ky_] := If[LessEqual[N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision], 0.022], N[Sqrt[N[(0.5 + N[(0.5 * N[Power[N[(1.0 + N[Power[N[(N[Sin[kx], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / Om), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\sin ky}^{2} \leq 0.022:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot {\left(1 + {\left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}^{2}\right)}^{-0.5}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 (sin.f64 ky) 2) < 0.021999999999999999

    1. Initial program 97.7%

      \[\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. Step-by-step derivation
      1. distribute-rgt-in97.7%

        \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
      2. metadata-eval97.7%

        \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      3. metadata-eval97.7%

        \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      4. associate-/l*97.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      5. metadata-eval97.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \color{blue}{0.5}} \]
    3. Simplified97.7%

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u97.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
      2. expm1-udef97.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
    6. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
      2. expm1-log1p100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
      3. *-commutative100.0%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      5. unpow297.9%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      6. unpow297.9%

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

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      9. unpow297.9%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      10. hypot-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      11. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
      12. associate-*l/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      13. associate-*r/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
    7. Simplified100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
    8. Taylor expanded in ky around 0 97.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sin kx} \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5} \]
    9. Step-by-step derivation
      1. inv-pow97.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{{\left(\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)\right)}^{-1}} \cdot 0.5} \]
      2. add-sqr-sqrt97.0%

        \[\leadsto \sqrt{0.5 + {\color{blue}{\left(\sqrt{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot \sqrt{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}\right)}}^{-1} \cdot 0.5} \]
      3. sqrt-unprod97.0%

        \[\leadsto \sqrt{0.5 + {\color{blue}{\left(\sqrt{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right) \cdot \mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}\right)}}^{-1} \cdot 0.5} \]
      4. sqrt-pow297.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{{\left(\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right) \cdot \mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)\right)}^{\left(\frac{-1}{2}\right)}} \cdot 0.5} \]
      5. hypot-udef97.0%

        \[\leadsto \sqrt{0.5 + {\left(\color{blue}{\sqrt{1 \cdot 1 + \left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right) \cdot \left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot \mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \cdot 0.5} \]
      6. hypot-udef97.0%

        \[\leadsto \sqrt{0.5 + {\left(\sqrt{1 \cdot 1 + \left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right) \cdot \left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot \color{blue}{\sqrt{1 \cdot 1 + \left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right) \cdot \left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\right)}^{\left(\frac{-1}{2}\right)} \cdot 0.5} \]
      7. add-sqr-sqrt97.0%

        \[\leadsto \sqrt{0.5 + {\color{blue}{\left(1 \cdot 1 + \left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right) \cdot \left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)\right)}}^{\left(\frac{-1}{2}\right)} \cdot 0.5} \]
      8. metadata-eval97.0%

        \[\leadsto \sqrt{0.5 + {\left(\color{blue}{1} + \left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right) \cdot \left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \cdot 0.5} \]
      9. pow297.0%

        \[\leadsto \sqrt{0.5 + {\left(1 + \color{blue}{{\left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}^{2}}\right)}^{\left(\frac{-1}{2}\right)} \cdot 0.5} \]
      10. metadata-eval97.0%

        \[\leadsto \sqrt{0.5 + {\left(1 + {\left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}^{2}\right)}^{\color{blue}{-0.5}} \cdot 0.5} \]
    10. Applied egg-rr97.0%

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

    if 0.021999999999999999 < (pow.f64 (sin.f64 ky) 2)

    1. Initial program 100.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. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      4. associate-/l*100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      5. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
      2. expm1-udef100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
    6. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
      2. expm1-log1p100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
      3. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)}\right)} \cdot 0.5} \]
      4. hypot-def100.0%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      6. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      8. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      9. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      10. hypot-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      11. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
      12. associate-*l/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      13. associate-*r/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
    7. Simplified100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
    8. Taylor expanded in kx around 0 98.5%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sin ky} \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5} \]
    9. Step-by-step derivation
      1. expm1-log1p-u97.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sin ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5}\right)\right)} \]
      2. expm1-udef97.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sin ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5}\right)} - 1} \]
      3. associate-*l/97.9%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{0.5 + \color{blue}{\frac{1 \cdot 0.5}{\mathsf{hypot}\left(1, \sin ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}}\right)} - 1 \]
      4. metadata-eval97.9%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{0.5 + \frac{\color{blue}{0.5}}{\mathsf{hypot}\left(1, \sin ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\right)} - 1 \]
      5. *-commutative97.9%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \color{blue}{\left(\ell \cdot \frac{2}{Om}\right) \cdot \sin ky}\right)}}\right)} - 1 \]
      6. associate-*l*97.9%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \color{blue}{\ell \cdot \left(\frac{2}{Om} \cdot \sin ky\right)}\right)}}\right)} - 1 \]
    10. Applied egg-rr97.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \left(\frac{2}{Om} \cdot \sin ky\right)\right)}}\right)} - 1} \]
    11. Step-by-step derivation
      1. expm1-def97.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \left(\frac{2}{Om} \cdot \sin ky\right)\right)}}\right)\right)} \]
      2. expm1-log1p98.5%

        \[\leadsto \color{blue}{\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \left(\frac{2}{Om} \cdot \sin ky\right)\right)}}} \]
      3. *-commutative98.5%

        \[\leadsto \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \color{blue}{\left(\sin ky \cdot \frac{2}{Om}\right)}\right)}} \]
      4. associate-*r*98.5%

        \[\leadsto \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \color{blue}{\left(\ell \cdot \sin ky\right) \cdot \frac{2}{Om}}\right)}} \]
    12. Simplified98.5%

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \left(\ell \cdot \sin ky\right) \cdot \frac{2}{Om}\right)}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.7%

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

Alternative 3: 98.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin ky}^{2} \leq 0.022:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(\sin ky \cdot \ell\right)\right)}}\\ \end{array} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (if (<= (pow (sin ky) 2.0) 0.022)
   (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) (* l (/ 2.0 Om)))))))
   (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ 2.0 Om) (* (sin ky) l))))))))
double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (pow(sin(ky), 2.0) <= 0.022) {
		tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (l * (2.0 / Om)))))));
	} else {
		tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l))))));
	}
	return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (Math.pow(Math.sin(ky), 2.0) <= 0.022) {
		tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) * (l * (2.0 / Om)))))));
	} else {
		tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 / Om) * (Math.sin(ky) * l))))));
	}
	return tmp;
}
def code(l, Om, kx, ky):
	tmp = 0
	if math.pow(math.sin(ky), 2.0) <= 0.022:
		tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) * (l * (2.0 / Om)))))))
	else:
		tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 / Om) * (math.sin(ky) * l))))))
	return tmp
function code(l, Om, kx, ky)
	tmp = 0.0
	if ((sin(ky) ^ 2.0) <= 0.022)
		tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * Float64(l * Float64(2.0 / Om)))))));
	else
		tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 / Om) * Float64(sin(ky) * l))))));
	end
	return tmp
end
function tmp_2 = code(l, Om, kx, ky)
	tmp = 0.0;
	if ((sin(ky) ^ 2.0) <= 0.022)
		tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (l * (2.0 / Om)))))));
	else
		tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l))))));
	end
	tmp_2 = tmp;
end
code[l_, Om_, kx_, ky_] := If[LessEqual[N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision], 0.022], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / Om), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\sin ky}^{2} \leq 0.022:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 (sin.f64 ky) 2) < 0.021999999999999999

    1. Initial program 97.7%

      \[\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. Step-by-step derivation
      1. distribute-rgt-in97.7%

        \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
      2. metadata-eval97.7%

        \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      3. metadata-eval97.7%

        \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      4. associate-/l*97.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      5. metadata-eval97.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \color{blue}{0.5}} \]
    3. Simplified97.7%

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u97.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
      2. expm1-udef97.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
    6. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
      2. expm1-log1p100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
      3. *-commutative100.0%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      5. unpow297.9%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      6. unpow297.9%

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

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      9. unpow297.9%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      10. hypot-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      11. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
      12. associate-*l/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      13. associate-*r/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
    7. Simplified100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
    8. Taylor expanded in ky around 0 97.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sin kx} \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5} \]
    9. Step-by-step derivation
      1. expm1-log1p-u97.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5\right)\right)}} \]
      2. expm1-udef97.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5\right)} - 1\right)}} \]
      3. associate-*l/97.0%

        \[\leadsto \sqrt{0.5 + \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{1 \cdot 0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\right)} - 1\right)} \]
      4. metadata-eval97.0%

        \[\leadsto \sqrt{0.5 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{0.5}}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}\right)} - 1\right)} \]
    10. Applied egg-rr97.0%

      \[\leadsto \sqrt{0.5 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}\right)} - 1\right)}} \]
    11. Step-by-step derivation
      1. expm1-def97.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}\right)\right)}} \]
      2. expm1-log1p97.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{\frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}} \]
    12. Simplified97.0%

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

    if 0.021999999999999999 < (pow.f64 (sin.f64 ky) 2)

    1. Initial program 100.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. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      4. associate-/l*100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      5. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
      2. expm1-udef100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
    6. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
      2. expm1-log1p100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
      3. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)}\right)} \cdot 0.5} \]
      4. hypot-def100.0%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      6. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      8. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      9. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      10. hypot-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      11. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
      12. associate-*l/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      13. associate-*r/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
    7. Simplified100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
    8. Taylor expanded in kx around 0 98.5%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sin ky} \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5} \]
    9. Step-by-step derivation
      1. expm1-log1p-u97.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sin ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5}\right)\right)} \]
      2. expm1-udef97.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sin ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5}\right)} - 1} \]
      3. associate-*l/97.9%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{0.5 + \color{blue}{\frac{1 \cdot 0.5}{\mathsf{hypot}\left(1, \sin ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}}\right)} - 1 \]
      4. metadata-eval97.9%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{0.5 + \frac{\color{blue}{0.5}}{\mathsf{hypot}\left(1, \sin ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\right)} - 1 \]
      5. *-commutative97.9%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \color{blue}{\left(\ell \cdot \frac{2}{Om}\right) \cdot \sin ky}\right)}}\right)} - 1 \]
      6. associate-*l*97.9%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \color{blue}{\ell \cdot \left(\frac{2}{Om} \cdot \sin ky\right)}\right)}}\right)} - 1 \]
    10. Applied egg-rr97.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \left(\frac{2}{Om} \cdot \sin ky\right)\right)}}\right)} - 1} \]
    11. Step-by-step derivation
      1. expm1-def97.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \left(\frac{2}{Om} \cdot \sin ky\right)\right)}}\right)\right)} \]
      2. expm1-log1p98.5%

        \[\leadsto \color{blue}{\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \left(\frac{2}{Om} \cdot \sin ky\right)\right)}}} \]
      3. *-commutative98.5%

        \[\leadsto \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \color{blue}{\left(\sin ky \cdot \frac{2}{Om}\right)}\right)}} \]
      4. associate-*r*98.5%

        \[\leadsto \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \color{blue}{\left(\ell \cdot \sin ky\right) \cdot \frac{2}{Om}}\right)}} \]
    12. Simplified98.5%

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \left(\ell \cdot \sin ky\right) \cdot \frac{2}{Om}\right)}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\sin ky}^{2} \leq 0.022:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(\sin ky \cdot \ell\right)\right)}}\\ \end{array} \]

Alternative 4: 94.5% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) (* l (/ 2.0 Om))))))))
double code(double l, double Om, double kx, double ky) {
	return sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (l * (2.0 / Om)))))));
}
public static double code(double l, double Om, double kx, double ky) {
	return Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) * (l * (2.0 / Om)))))));
}
def code(l, Om, kx, ky):
	return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) * (l * (2.0 / Om)))))))
function code(l, Om, kx, ky)
	return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * Float64(l * Float64(2.0 / Om)))))))
end
function tmp = code(l, Om, kx, ky)
	tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (l * (2.0 / Om)))))));
end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}
\end{array}
Derivation
  1. Initial program 98.8%

    \[\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. Step-by-step derivation
    1. distribute-rgt-in98.8%

      \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
    2. metadata-eval98.8%

      \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
    3. metadata-eval98.8%

      \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
    4. associate-/l*98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
    5. metadata-eval98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \color{blue}{0.5}} \]
  3. Simplified98.8%

    \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
  4. Step-by-step derivation
    1. expm1-log1p-u98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
    2. expm1-udef98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
  5. Applied egg-rr100.0%

    \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
  6. Step-by-step derivation
    1. expm1-def100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
    2. expm1-log1p100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
    3. *-commutative100.0%

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

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    5. unpow298.9%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    6. unpow298.9%

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

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

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    9. unpow298.9%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    10. hypot-def100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    11. *-commutative100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
    12. associate-*l/100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
    13. associate-*r/100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
  7. Simplified100.0%

    \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
  8. Taylor expanded in ky around 0 94.2%

    \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sin kx} \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5} \]
  9. Step-by-step derivation
    1. expm1-log1p-u94.2%

      \[\leadsto \sqrt{0.5 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5\right)\right)}} \]
    2. expm1-udef94.2%

      \[\leadsto \sqrt{0.5 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5\right)} - 1\right)}} \]
    3. associate-*l/94.2%

      \[\leadsto \sqrt{0.5 + \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{1 \cdot 0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\right)} - 1\right)} \]
    4. metadata-eval94.2%

      \[\leadsto \sqrt{0.5 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{0.5}}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}\right)} - 1\right)} \]
  10. Applied egg-rr94.2%

    \[\leadsto \sqrt{0.5 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}\right)} - 1\right)}} \]
  11. Step-by-step derivation
    1. expm1-def94.2%

      \[\leadsto \sqrt{0.5 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}\right)\right)}} \]
    2. expm1-log1p94.2%

      \[\leadsto \sqrt{0.5 + \color{blue}{\frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}} \]
  12. Simplified94.2%

    \[\leadsto \sqrt{0.5 + \color{blue}{\frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}} \]
  13. Final simplification94.2%

    \[\leadsto \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \]

Alternative 5: 67.5% accurate, 6.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4.8 \cdot 10^{+57}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{elif}\;\ell \leq -3.8 \cdot 10^{-19} \lor \neg \left(\ell \leq -1.02 \cdot 10^{-76}\right) \land \ell \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;1 + \frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om}{ky} \cdot \frac{Om}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (if (<= l -4.8e+57)
   (sqrt 0.5)
   (if (or (<= l -3.8e-19) (and (not (<= l -1.02e-76)) (<= l 1.22e-26)))
     (+ 1.0 (/ (* -0.5 (* l l)) (* (/ Om ky) (/ Om ky))))
     (sqrt 0.5))))
double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (l <= -4.8e+57) {
		tmp = sqrt(0.5);
	} else if ((l <= -3.8e-19) || (!(l <= -1.02e-76) && (l <= 1.22e-26))) {
		tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)));
	} else {
		tmp = sqrt(0.5);
	}
	return tmp;
}
real(8) function code(l, om, kx, ky)
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: tmp
    if (l <= (-4.8d+57)) then
        tmp = sqrt(0.5d0)
    else if ((l <= (-3.8d-19)) .or. (.not. (l <= (-1.02d-76))) .and. (l <= 1.22d-26)) then
        tmp = 1.0d0 + (((-0.5d0) * (l * l)) / ((om / ky) * (om / ky)))
    else
        tmp = sqrt(0.5d0)
    end if
    code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (l <= -4.8e+57) {
		tmp = Math.sqrt(0.5);
	} else if ((l <= -3.8e-19) || (!(l <= -1.02e-76) && (l <= 1.22e-26))) {
		tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)));
	} else {
		tmp = Math.sqrt(0.5);
	}
	return tmp;
}
def code(l, Om, kx, ky):
	tmp = 0
	if l <= -4.8e+57:
		tmp = math.sqrt(0.5)
	elif (l <= -3.8e-19) or (not (l <= -1.02e-76) and (l <= 1.22e-26)):
		tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)))
	else:
		tmp = math.sqrt(0.5)
	return tmp
function code(l, Om, kx, ky)
	tmp = 0.0
	if (l <= -4.8e+57)
		tmp = sqrt(0.5);
	elseif ((l <= -3.8e-19) || (!(l <= -1.02e-76) && (l <= 1.22e-26)))
		tmp = Float64(1.0 + Float64(Float64(-0.5 * Float64(l * l)) / Float64(Float64(Om / ky) * Float64(Om / ky))));
	else
		tmp = sqrt(0.5);
	end
	return tmp
end
function tmp_2 = code(l, Om, kx, ky)
	tmp = 0.0;
	if (l <= -4.8e+57)
		tmp = sqrt(0.5);
	elseif ((l <= -3.8e-19) || (~((l <= -1.02e-76)) && (l <= 1.22e-26)))
		tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)));
	else
		tmp = sqrt(0.5);
	end
	tmp_2 = tmp;
end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, -4.8e+57], N[Sqrt[0.5], $MachinePrecision], If[Or[LessEqual[l, -3.8e-19], And[N[Not[LessEqual[l, -1.02e-76]], $MachinePrecision], LessEqual[l, 1.22e-26]]], N[(1.0 + N[(N[(-0.5 * N[(l * l), $MachinePrecision]), $MachinePrecision] / N[(N[(Om / ky), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.8 \cdot 10^{+57}:\\
\;\;\;\;\sqrt{0.5}\\

\mathbf{elif}\;\ell \leq -3.8 \cdot 10^{-19} \lor \neg \left(\ell \leq -1.02 \cdot 10^{-76}\right) \land \ell \leq 1.22 \cdot 10^{-26}:\\
\;\;\;\;1 + \frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om}{ky} \cdot \frac{Om}{ky}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.80000000000000009e57 or -3.8e-19 < l < -1.02000000000000006e-76 or 1.22e-26 < l

    1. Initial program 97.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. Step-by-step derivation
      1. distribute-rgt-in97.4%

        \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
      2. metadata-eval97.4%

        \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      3. metadata-eval97.4%

        \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      4. associate-/l*97.4%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      5. metadata-eval97.4%

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

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
    4. Taylor expanded in l around -inf 69.1%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{-2 \cdot \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}} \cdot \frac{\ell}{Om}\right)}} \cdot 0.5} \]
    5. Step-by-step derivation
      1. *-commutative69.1%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}} \cdot \frac{\ell}{Om}\right) \cdot -2}} \cdot 0.5} \]
      2. associate-*l*69.1%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}} \cdot \left(\frac{\ell}{Om} \cdot -2\right)}} \cdot 0.5} \]
      3. unpow269.1%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(\frac{\ell}{Om} \cdot -2\right)} \cdot 0.5} \]
      5. hypot-def71.6%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(\frac{\ell}{Om} \cdot -2\right)} \cdot 0.5} \]
    6. Simplified71.6%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\frac{\ell}{Om} \cdot -2\right)}} \cdot 0.5} \]
    7. Taylor expanded in l around inf 76.3%

      \[\leadsto \color{blue}{\sqrt{0.5}} \]

    if -4.80000000000000009e57 < l < -3.8e-19 or -1.02000000000000006e-76 < l < 1.22e-26

    1. Initial program 100.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. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      4. associate-/l*100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      5. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
      2. expm1-udef100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
    6. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
      2. expm1-log1p100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
      3. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)}\right)} \cdot 0.5} \]
      4. hypot-def100.0%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      6. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      8. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      9. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      10. hypot-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      11. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
      12. associate-*l/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      13. associate-*r/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
    7. Simplified100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
    8. Taylor expanded in kx around 0 97.3%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sin ky} \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5} \]
    9. Taylor expanded in ky around 0 61.7%

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{\ell}^{2} \cdot {ky}^{2}}{{Om}^{2}}} \]
    10. Step-by-step derivation
      1. associate-/l*59.5%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{{\ell}^{2}}{\frac{{Om}^{2}}{{ky}^{2}}}} \]
      2. unpow259.5%

        \[\leadsto 1 + -0.5 \cdot \frac{\color{blue}{\ell \cdot \ell}}{\frac{{Om}^{2}}{{ky}^{2}}} \]
      3. unpow259.5%

        \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{\color{blue}{Om \cdot Om}}{{ky}^{2}}} \]
      4. unpow259.5%

        \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{\color{blue}{ky \cdot ky}}} \]
    11. Simplified59.5%

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}} \]
    12. Step-by-step derivation
      1. associate-*r/59.5%

        \[\leadsto 1 + \color{blue}{\frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om \cdot Om}{ky \cdot ky}}} \]
      2. times-frac75.8%

        \[\leadsto 1 + \frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\color{blue}{\frac{Om}{ky} \cdot \frac{Om}{ky}}} \]
    13. Applied egg-rr75.8%

      \[\leadsto 1 + \color{blue}{\frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om}{ky} \cdot \frac{Om}{ky}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.8 \cdot 10^{+57}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{elif}\;\ell \leq -3.8 \cdot 10^{-19} \lor \neg \left(\ell \leq -1.02 \cdot 10^{-76}\right) \land \ell \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;1 + \frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om}{ky} \cdot \frac{Om}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \]

Alternative 6: 78.2% accurate, 6.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4 \cdot 10^{+68}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{elif}\;\ell \leq 1.14 \cdot 10^{-26}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (if (<= l -4e+68) (sqrt 0.5) (if (<= l 1.14e-26) 1.0 (sqrt 0.5))))
double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (l <= -4e+68) {
		tmp = sqrt(0.5);
	} else if (l <= 1.14e-26) {
		tmp = 1.0;
	} else {
		tmp = sqrt(0.5);
	}
	return tmp;
}
real(8) function code(l, om, kx, ky)
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: tmp
    if (l <= (-4d+68)) then
        tmp = sqrt(0.5d0)
    else if (l <= 1.14d-26) then
        tmp = 1.0d0
    else
        tmp = sqrt(0.5d0)
    end if
    code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (l <= -4e+68) {
		tmp = Math.sqrt(0.5);
	} else if (l <= 1.14e-26) {
		tmp = 1.0;
	} else {
		tmp = Math.sqrt(0.5);
	}
	return tmp;
}
def code(l, Om, kx, ky):
	tmp = 0
	if l <= -4e+68:
		tmp = math.sqrt(0.5)
	elif l <= 1.14e-26:
		tmp = 1.0
	else:
		tmp = math.sqrt(0.5)
	return tmp
function code(l, Om, kx, ky)
	tmp = 0.0
	if (l <= -4e+68)
		tmp = sqrt(0.5);
	elseif (l <= 1.14e-26)
		tmp = 1.0;
	else
		tmp = sqrt(0.5);
	end
	return tmp
end
function tmp_2 = code(l, Om, kx, ky)
	tmp = 0.0;
	if (l <= -4e+68)
		tmp = sqrt(0.5);
	elseif (l <= 1.14e-26)
		tmp = 1.0;
	else
		tmp = sqrt(0.5);
	end
	tmp_2 = tmp;
end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, -4e+68], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, 1.14e-26], 1.0, N[Sqrt[0.5], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4 \cdot 10^{+68}:\\
\;\;\;\;\sqrt{0.5}\\

\mathbf{elif}\;\ell \leq 1.14 \cdot 10^{-26}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -3.99999999999999981e68 or 1.1399999999999999e-26 < l

    1. Initial program 97.2%

      \[\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. Step-by-step derivation
      1. distribute-rgt-in97.2%

        \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
      2. metadata-eval97.2%

        \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      3. metadata-eval97.2%

        \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      4. associate-/l*97.2%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      5. metadata-eval97.2%

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

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
    4. Taylor expanded in l around -inf 69.5%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{-2 \cdot \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}} \cdot \frac{\ell}{Om}\right)}} \cdot 0.5} \]
    5. Step-by-step derivation
      1. *-commutative69.5%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}} \cdot \frac{\ell}{Om}\right) \cdot -2}} \cdot 0.5} \]
      2. associate-*l*69.5%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}} \cdot \left(\frac{\ell}{Om} \cdot -2\right)}} \cdot 0.5} \]
      3. unpow269.5%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(\frac{\ell}{Om} \cdot -2\right)} \cdot 0.5} \]
      5. hypot-def72.3%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(\frac{\ell}{Om} \cdot -2\right)} \cdot 0.5} \]
    6. Simplified72.3%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\frac{\ell}{Om} \cdot -2\right)}} \cdot 0.5} \]
    7. Taylor expanded in l around inf 76.8%

      \[\leadsto \color{blue}{\sqrt{0.5}} \]

    if -3.99999999999999981e68 < l < 1.1399999999999999e-26

    1. Initial program 100.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. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      4. associate-/l*100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      5. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
      2. expm1-udef100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
    6. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
      2. expm1-log1p100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
      3. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)}\right)} \cdot 0.5} \]
      4. hypot-def100.0%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      6. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      8. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      9. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      10. hypot-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      11. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
      12. associate-*l/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      13. associate-*r/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
    7. Simplified100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
    8. Taylor expanded in ky around 0 96.6%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sin kx} \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5} \]
    9. Taylor expanded in kx around 0 89.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4 \cdot 10^{+68}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{elif}\;\ell \leq 1.14 \cdot 10^{-26}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \]

Alternative 7: 41.5% accurate, 42.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 9 \cdot 10^{+150}:\\ \;\;\;\;1 + -0.5 \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om}{ky} \cdot \frac{Om}{ky}}\\ \end{array} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (if (<= ky 9e+150)
   (+ 1.0 (* -0.5 (* (* (/ l Om) (/ l Om)) (* ky ky))))
   (+ 1.0 (/ (* -0.5 (* l l)) (* (/ Om ky) (/ Om ky))))))
double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (ky <= 9e+150) {
		tmp = 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)));
	} else {
		tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)));
	}
	return tmp;
}
real(8) function code(l, om, kx, ky)
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: tmp
    if (ky <= 9d+150) then
        tmp = 1.0d0 + ((-0.5d0) * (((l / om) * (l / om)) * (ky * ky)))
    else
        tmp = 1.0d0 + (((-0.5d0) * (l * l)) / ((om / ky) * (om / ky)))
    end if
    code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (ky <= 9e+150) {
		tmp = 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)));
	} else {
		tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)));
	}
	return tmp;
}
def code(l, Om, kx, ky):
	tmp = 0
	if ky <= 9e+150:
		tmp = 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)))
	else:
		tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)))
	return tmp
function code(l, Om, kx, ky)
	tmp = 0.0
	if (ky <= 9e+150)
		tmp = Float64(1.0 + Float64(-0.5 * Float64(Float64(Float64(l / Om) * Float64(l / Om)) * Float64(ky * ky))));
	else
		tmp = Float64(1.0 + Float64(Float64(-0.5 * Float64(l * l)) / Float64(Float64(Om / ky) * Float64(Om / ky))));
	end
	return tmp
end
function tmp_2 = code(l, Om, kx, ky)
	tmp = 0.0;
	if (ky <= 9e+150)
		tmp = 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)));
	else
		tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)));
	end
	tmp_2 = tmp;
end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 9e+150], N[(1.0 + N[(-0.5 * N[(N[(N[(l / Om), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(-0.5 * N[(l * l), $MachinePrecision]), $MachinePrecision] / N[(N[(Om / ky), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 9 \cdot 10^{+150}:\\
\;\;\;\;1 + -0.5 \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\right)\right)\\

\mathbf{else}:\\
\;\;\;\;1 + \frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om}{ky} \cdot \frac{Om}{ky}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < 9.00000000000000001e150

    1. Initial program 98.7%

      \[\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. Step-by-step derivation
      1. distribute-rgt-in98.7%

        \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
      2. metadata-eval98.7%

        \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      3. metadata-eval98.7%

        \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      4. associate-/l*98.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      5. metadata-eval98.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \color{blue}{0.5}} \]
    3. Simplified98.7%

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u98.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
      2. expm1-udef98.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
    6. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
      2. expm1-log1p100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
      3. *-commutative100.0%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      5. unpow298.8%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      6. unpow298.8%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      7. +-commutative98.8%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      8. unpow298.8%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      10. hypot-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      11. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
      12. associate-*l/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      13. associate-*r/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
    7. Simplified100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
    8. Taylor expanded in kx around 0 94.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sin ky} \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5} \]
    9. Taylor expanded in ky around 0 42.2%

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{\ell}^{2} \cdot {ky}^{2}}{{Om}^{2}}} \]
    10. Step-by-step derivation
      1. associate-/l*41.4%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{{\ell}^{2}}{\frac{{Om}^{2}}{{ky}^{2}}}} \]
      2. unpow241.4%

        \[\leadsto 1 + -0.5 \cdot \frac{\color{blue}{\ell \cdot \ell}}{\frac{{Om}^{2}}{{ky}^{2}}} \]
      3. unpow241.4%

        \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{\color{blue}{Om \cdot Om}}{{ky}^{2}}} \]
      4. unpow241.4%

        \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{\color{blue}{ky \cdot ky}}} \]
    11. Simplified41.4%

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}} \]
    12. Taylor expanded in l around 0 42.2%

      \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{{\ell}^{2} \cdot {ky}^{2}}{{Om}^{2}}} \]
    13. Step-by-step derivation
      1. associate-*l/42.5%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(\frac{{\ell}^{2}}{{Om}^{2}} \cdot {ky}^{2}\right)} \]
      2. unpow242.5%

        \[\leadsto 1 + -0.5 \cdot \left(\frac{\color{blue}{\ell \cdot \ell}}{{Om}^{2}} \cdot {ky}^{2}\right) \]
      3. unpow242.5%

        \[\leadsto 1 + -0.5 \cdot \left(\frac{\ell \cdot \ell}{\color{blue}{Om \cdot Om}} \cdot {ky}^{2}\right) \]
      4. unpow242.5%

        \[\leadsto 1 + -0.5 \cdot \left(\frac{\ell \cdot \ell}{Om \cdot Om} \cdot \color{blue}{\left(ky \cdot ky\right)}\right) \]
      5. times-frac49.8%

        \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)} \cdot \left(ky \cdot ky\right)\right) \]
    14. Simplified49.8%

      \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\right)\right)} \]

    if 9.00000000000000001e150 < ky

    1. Initial program 100.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. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      4. associate-/l*100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
      5. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
      2. expm1-udef100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
    6. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
      2. expm1-log1p100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
      3. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)}\right)} \cdot 0.5} \]
      4. hypot-def100.0%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      6. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      8. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      9. unpow2100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      10. hypot-def100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
      11. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
      12. associate-*l/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      13. associate-*r/100.0%

        \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
    7. Simplified100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
    8. Taylor expanded in kx around 0 99.5%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sin ky} \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5} \]
    9. Taylor expanded in ky around 0 3.7%

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{\ell}^{2} \cdot {ky}^{2}}{{Om}^{2}}} \]
    10. Step-by-step derivation
      1. associate-/l*3.7%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{{\ell}^{2}}{\frac{{Om}^{2}}{{ky}^{2}}}} \]
      2. unpow23.7%

        \[\leadsto 1 + -0.5 \cdot \frac{\color{blue}{\ell \cdot \ell}}{\frac{{Om}^{2}}{{ky}^{2}}} \]
      3. unpow23.7%

        \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{\color{blue}{Om \cdot Om}}{{ky}^{2}}} \]
      4. unpow23.7%

        \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{\color{blue}{ky \cdot ky}}} \]
    11. Simplified3.7%

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}} \]
    12. Step-by-step derivation
      1. associate-*r/3.7%

        \[\leadsto 1 + \color{blue}{\frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om \cdot Om}{ky \cdot ky}}} \]
      2. times-frac31.4%

        \[\leadsto 1 + \frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\color{blue}{\frac{Om}{ky} \cdot \frac{Om}{ky}}} \]
    13. Applied egg-rr31.4%

      \[\leadsto 1 + \color{blue}{\frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om}{ky} \cdot \frac{Om}{ky}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification47.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 9 \cdot 10^{+150}:\\ \;\;\;\;1 + -0.5 \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om}{ky} \cdot \frac{Om}{ky}}\\ \end{array} \]

Alternative 8: 39.4% accurate, 48.1× speedup?

\[\begin{array}{l} \\ 1 + -0.5 \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\right)\right) \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (+ 1.0 (* -0.5 (* (* (/ l Om) (/ l Om)) (* ky ky)))))
double code(double l, double Om, double kx, double ky) {
	return 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)));
}
real(8) function code(l, om, kx, ky)
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    code = 1.0d0 + ((-0.5d0) * (((l / om) * (l / om)) * (ky * ky)))
end function
public static double code(double l, double Om, double kx, double ky) {
	return 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)));
}
def code(l, Om, kx, ky):
	return 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)))
function code(l, Om, kx, ky)
	return Float64(1.0 + Float64(-0.5 * Float64(Float64(Float64(l / Om) * Float64(l / Om)) * Float64(ky * ky))))
end
function tmp = code(l, Om, kx, ky)
	tmp = 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)));
end
code[l_, Om_, kx_, ky_] := N[(1.0 + N[(-0.5 * N[(N[(N[(l / Om), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 + -0.5 \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\right)\right)
\end{array}
Derivation
  1. Initial program 98.8%

    \[\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. Step-by-step derivation
    1. distribute-rgt-in98.8%

      \[\leadsto \sqrt{\color{blue}{1 \cdot \frac{1}{2} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}}} \]
    2. metadata-eval98.8%

      \[\leadsto \sqrt{1 \cdot \color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
    3. metadata-eval98.8%

      \[\leadsto \sqrt{\color{blue}{0.5} + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
    4. associate-/l*98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\color{blue}{\left(\frac{2}{\frac{Om}{\ell}}\right)}}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \frac{1}{2}} \]
    5. metadata-eval98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot \color{blue}{0.5}} \]
  3. Simplified98.8%

    \[\leadsto \color{blue}{\sqrt{0.5 + \frac{1}{\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} \cdot 0.5}} \]
  4. Step-by-step derivation
    1. expm1-log1p-u98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)\right)}} \cdot 0.5} \]
    2. expm1-udef98.8%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{1 + {\left(\frac{2}{\frac{Om}{\ell}}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}\right)} - 1}} \cdot 0.5} \]
  5. Applied egg-rr100.0%

    \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)} - 1}} \cdot 0.5} \]
  6. Step-by-step derivation
    1. expm1-def100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)\right)}} \cdot 0.5} \]
    2. expm1-log1p100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}} \cdot 0.5} \]
    3. *-commutative100.0%

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

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    5. unpow298.9%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{{\sin kx}^{2}} + \sin ky \cdot \sin ky} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    6. unpow298.9%

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

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

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    9. unpow298.9%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    10. hypot-def100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)} \cdot 0.5} \]
    11. *-commutative100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot 2\right)}\right)} \cdot 0.5} \]
    12. associate-*l/100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
    13. associate-*r/100.0%

      \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \frac{2}{Om}\right)}\right)} \cdot 0.5} \]
  7. Simplified100.0%

    \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
  8. Taylor expanded in kx around 0 94.6%

    \[\leadsto \sqrt{0.5 + \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sin ky} \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)} \cdot 0.5} \]
  9. Taylor expanded in ky around 0 37.9%

    \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{\ell}^{2} \cdot {ky}^{2}}{{Om}^{2}}} \]
  10. Step-by-step derivation
    1. associate-/l*37.1%

      \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{{\ell}^{2}}{\frac{{Om}^{2}}{{ky}^{2}}}} \]
    2. unpow237.1%

      \[\leadsto 1 + -0.5 \cdot \frac{\color{blue}{\ell \cdot \ell}}{\frac{{Om}^{2}}{{ky}^{2}}} \]
    3. unpow237.1%

      \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{\color{blue}{Om \cdot Om}}{{ky}^{2}}} \]
    4. unpow237.1%

      \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{\color{blue}{ky \cdot ky}}} \]
  11. Simplified37.1%

    \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}} \]
  12. Taylor expanded in l around 0 37.9%

    \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{{\ell}^{2} \cdot {ky}^{2}}{{Om}^{2}}} \]
  13. Step-by-step derivation
    1. associate-*l/38.1%

      \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(\frac{{\ell}^{2}}{{Om}^{2}} \cdot {ky}^{2}\right)} \]
    2. unpow238.1%

      \[\leadsto 1 + -0.5 \cdot \left(\frac{\color{blue}{\ell \cdot \ell}}{{Om}^{2}} \cdot {ky}^{2}\right) \]
    3. unpow238.1%

      \[\leadsto 1 + -0.5 \cdot \left(\frac{\ell \cdot \ell}{\color{blue}{Om \cdot Om}} \cdot {ky}^{2}\right) \]
    4. unpow238.1%

      \[\leadsto 1 + -0.5 \cdot \left(\frac{\ell \cdot \ell}{Om \cdot Om} \cdot \color{blue}{\left(ky \cdot ky\right)}\right) \]
    5. times-frac44.6%

      \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)} \cdot \left(ky \cdot ky\right)\right) \]
  14. Simplified44.6%

    \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\right)\right)} \]
  15. Final simplification44.6%

    \[\leadsto 1 + -0.5 \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\right)\right) \]

Reproduce

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