Toniolo and Linder, Equation (3a)

Percentage Accurate: 98.4% → 100.0%
Time: 18.8s
Alternatives: 7
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 7 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.4% 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 kx, \sin ky\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (sqrt
  (+
   0.5
   (*
    0.5
    (/ 1.0 (hypot 1.0 (* (hypot (sin kx) (sin ky)) (* 2.0 (/ l Om)))))))))
double code(double l, double Om, double kx, double ky) {
	return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (hypot(sin(kx), sin(ky)) * (2.0 * (l / 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(kx), Math.sin(ky)) * (2.0 * (l / Om))))))));
}
def code(l, Om, kx, ky):
	return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (math.hypot(math.sin(kx), math.sin(ky)) * (2.0 * (l / Om))))))))
function code(l, Om, kx, ky)
	return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(hypot(sin(kx), sin(ky)) * Float64(2.0 * Float64(l / Om))))))))
end
function tmp = code(l, Om, kx, ky)
	tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (hypot(sin(kx), sin(ky)) * (2.0 * (l / 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[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(2.0 * N[(l / 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 kx, \sin ky\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}
\end{array}
Derivation
  1. Initial program 97.3%

    \[\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. Simplified97.3%

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \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)}}} \]
    2. expm1-udef97.3%

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \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}}} \]
  4. Applied egg-rr100.0%

    \[\leadsto \sqrt{0.5 + 0.5 \cdot \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}}} \]
  5. Step-by-step derivation
    1. expm1-def100.0%

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \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)}}} \]
    2. expm1-log1p100.0%

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \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)}}} \]
    3. *-commutative100.0%

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \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)}} \]
  6. Simplified100.0%

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

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

Alternative 2: 93.3% accurate, 2.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 2 l) Om) < 10

    1. Initial program 98.9%

      \[\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. Simplified98.9%

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \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)}}} \]
      2. expm1-udef98.9%

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \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}}} \]
    4. Applied egg-rr100.0%

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \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}}} \]
    5. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \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)}}} \]
      2. expm1-log1p100.0%

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \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)}}} \]
      3. *-commutative100.0%

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \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)}} \]
    6. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

    if 10 < (/.f64 (*.f64 2 l) Om)

    1. Initial program 92.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. Simplified92.8%

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}}}} \]
    4. Step-by-step derivation
      1. associate-*r/63.4%

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

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

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

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{\frac{\left(4 \cdot \left(\ell \cdot \ell\right)\right) \cdot {\sin ky}^{2}}{Om \cdot Om}}}}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt63.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\sin ky \cdot \left(\color{blue}{\ell} \cdot \sqrt{4}\right)}{\sqrt{Om \cdot Om}}\right)}} \]
      13. metadata-eval86.5%

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\sin ky \cdot \left(\ell \cdot 2\right)}{Om}\right)}}\right)} - 1} \]
      3. un-div-inv92.8%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 93.7% accurate, 2.3× speedup?

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

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

    \[\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. Simplified97.3%

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

    \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}}}} \]
  4. Step-by-step derivation
    1. associate-*r/77.3%

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

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

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

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

    \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{\frac{\left(4 \cdot \left(\ell \cdot \ell\right)\right) \cdot {\sin ky}^{2}}{Om \cdot Om}}}}} \]
  6. Step-by-step derivation
    1. add-sqr-sqrt77.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\sin ky \cdot \left(\color{blue}{\left(\sqrt{\ell} \cdot \sqrt{\ell}\right)} \cdot \sqrt{4}\right)}{\sqrt{Om \cdot Om}}\right)}} \]
    12. add-sqr-sqrt89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 85.3% accurate, 3.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if Om < 5.5000000000000002e96

    1. Initial program 96.9%

      \[\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. Simplified96.9%

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}}}} \]
    4. Step-by-step derivation
      1. associate-*r/76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\sin ky \cdot \left(\ell \cdot 2\right)}{Om}\right)}}\right)} - 1} \]
      3. un-div-inv94.7%

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

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

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

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

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

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

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

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

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

    if 5.5000000000000002e96 < Om

    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. Simplified100.0%

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}}}} \]
    4. Step-by-step derivation
      1. associate-*r/83.3%

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

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

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

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{\frac{\left(4 \cdot \left(\ell \cdot \ell\right)\right) \cdot {\sin ky}^{2}}{Om \cdot Om}}}}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt83.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\sin ky \cdot \left(\color{blue}{\left(\sqrt{\ell} \cdot \sqrt{\ell}\right)} \cdot \sqrt{4}\right)}{\sqrt{Om \cdot Om}}\right)}} \]
      12. add-sqr-sqrt94.7%

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\sin ky \cdot \left(\color{blue}{\ell} \cdot \sqrt{4}\right)}{\sqrt{Om \cdot Om}}\right)}} \]
      13. metadata-eval94.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.5%

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

Alternative 5: 71.5% accurate, 5.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.6 \cdot 10^{-23}:\\ \;\;\;\;1\\ \mathbf{elif}\;\ell \leq 1.06 \cdot 10^{+127}:\\ \;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{ky \cdot ky}{\frac{Om \cdot Om}{\ell \cdot \ell}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (if (<= l 1.6e-23)
   1.0
   (if (<= l 1.06e+127)
     (sqrt
      (+
       0.5
       (* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (/ (* ky ky) (/ (* Om Om) (* l l)))))))))
     (sqrt 0.5))))
double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (l <= 1.6e-23) {
		tmp = 1.0;
	} else if (l <= 1.06e+127) {
		tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l)))))))));
	} 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 <= 1.6d-23) then
        tmp = 1.0d0
    else if (l <= 1.06d+127) then
        tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((ky * ky) / ((om * om) / (l * l)))))))))
    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 <= 1.6e-23) {
		tmp = 1.0;
	} else if (l <= 1.06e+127) {
		tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l)))))))));
	} else {
		tmp = Math.sqrt(0.5);
	}
	return tmp;
}
def code(l, Om, kx, ky):
	tmp = 0
	if l <= 1.6e-23:
		tmp = 1.0
	elif l <= 1.06e+127:
		tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l)))))))))
	else:
		tmp = math.sqrt(0.5)
	return tmp
function code(l, Om, kx, ky)
	tmp = 0.0
	if (l <= 1.6e-23)
		tmp = 1.0;
	elseif (l <= 1.06e+127)
		tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(ky * ky) / Float64(Float64(Om * Om) / Float64(l * l)))))))));
	else
		tmp = sqrt(0.5);
	end
	return tmp
end
function tmp_2 = code(l, Om, kx, ky)
	tmp = 0.0;
	if (l <= 1.6e-23)
		tmp = 1.0;
	elseif (l <= 1.06e+127)
		tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l)))))))));
	else
		tmp = sqrt(0.5);
	end
	tmp_2 = tmp;
end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.6e-23], 1.0, If[LessEqual[l, 1.06e+127], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(ky * ky), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.6 \cdot 10^{-23}:\\
\;\;\;\;1\\

\mathbf{elif}\;\ell \leq 1.06 \cdot 10^{+127}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{ky \cdot ky}{\frac{Om \cdot Om}{\ell \cdot \ell}}}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < 1.59999999999999988e-23

    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. Simplified97.4%

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}}}} \]
    4. Step-by-step derivation
      1. associate-*r/77.3%

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

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

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

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{\frac{\left(4 \cdot \left(\ell \cdot \ell\right)\right) \cdot {\sin ky}^{2}}{Om \cdot Om}}}}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt77.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\sin ky \cdot \left(\color{blue}{\left(\sqrt{\ell} \cdot \sqrt{\ell}\right)} \cdot \sqrt{4}\right)}{\sqrt{Om \cdot Om}}\right)}} \]
      12. add-sqr-sqrt89.1%

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\sin ky \cdot \left(\ell \cdot 2\right)}{Om}\right)}}\right)} - 1} \]
      3. un-div-inv96.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1} \]

    if 1.59999999999999988e-23 < l < 1.06000000000000006e127

    1. Initial program 92.6%

      \[\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. Simplified92.6%

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}}}} \]
    4. Step-by-step derivation
      1. associate-*r/77.0%

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

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

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

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{\frac{\left(4 \cdot \left(\ell \cdot \ell\right)\right) \cdot {\sin ky}^{2}}{Om \cdot Om}}}}} \]
    6. Taylor expanded in ky around 0 68.2%

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{ky \cdot ky}{\frac{Om \cdot Om}{\color{blue}{\ell \cdot \ell}}}}} \]
    8. Simplified67.4%

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\color{blue}{1 + 2 \cdot \frac{ky \cdot ky}{\frac{Om \cdot Om}{\ell \cdot \ell}}}}} \]

    if 1.06000000000000006e127 < l

    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. Simplified100.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.6 \cdot 10^{-23}:\\ \;\;\;\;1\\ \mathbf{elif}\;\ell \leq 1.06 \cdot 10^{+127}:\\ \;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{ky \cdot ky}{\frac{Om \cdot Om}{\ell \cdot \ell}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \]

Alternative 6: 70.0% accurate, 7.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 24500000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
(FPCore (l Om kx ky) :precision binary64 (if (<= l 24500000.0) 1.0 (sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (l <= 24500000.0) {
		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 <= 24500000.0d0) 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 <= 24500000.0) {
		tmp = 1.0;
	} else {
		tmp = Math.sqrt(0.5);
	}
	return tmp;
}
def code(l, Om, kx, ky):
	tmp = 0
	if l <= 24500000.0:
		tmp = 1.0
	else:
		tmp = math.sqrt(0.5)
	return tmp
function code(l, Om, kx, ky)
	tmp = 0.0
	if (l <= 24500000.0)
		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 <= 24500000.0)
		tmp = 1.0;
	else
		tmp = sqrt(0.5);
	end
	tmp_2 = tmp;
end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 24500000.0], 1.0, N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 24500000:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 2.45e7

    1. Initial program 97.5%

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

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}}}} \]
    4. Step-by-step derivation
      1. associate-*r/77.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1} \]

    if 2.45e7 < l

    1. Initial program 96.6%

      \[\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. Simplified96.6%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 24500000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \]

Alternative 7: 62.0% accurate, 722.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (l Om kx ky) :precision binary64 1.0)
double code(double l, double Om, double kx, double ky) {
	return 1.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 = 1.0d0
end function
public static double code(double l, double Om, double kx, double ky) {
	return 1.0;
}
def code(l, Om, kx, ky):
	return 1.0
function code(l, Om, kx, ky)
	return 1.0
end
function tmp = code(l, Om, kx, ky)
	tmp = 1.0;
end
code[l_, Om_, kx_, ky_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 97.3%

    \[\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. Simplified97.3%

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

    \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}}}} \]
  4. Step-by-step derivation
    1. associate-*r/77.3%

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

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

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

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

    \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \color{blue}{\frac{\left(4 \cdot \left(\ell \cdot \ell\right)\right) \cdot {\sin ky}^{2}}{Om \cdot Om}}}}} \]
  6. Step-by-step derivation
    1. add-sqr-sqrt77.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\sin ky \cdot \left(\color{blue}{\left(\sqrt{\ell} \cdot \sqrt{\ell}\right)} \cdot \sqrt{4}\right)}{\sqrt{Om \cdot Om}}\right)}} \]
    12. add-sqr-sqrt89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{1} \]
  13. Final simplification59.7%

    \[\leadsto 1 \]

Reproduce

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