Toniolo and Linder, Equation (3a)

Percentage Accurate: 98.1% → 99.0%
Time: 16.3s
Alternatives: 11
Speedup: 1.1×

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 11 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.1% 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: 99.0% accurate, 1.1× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ \begin{array}{l} \mathbf{if}\;\frac{2 \cdot l\_m}{Om\_m} \leq 10^{+115}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{1 + \frac{l\_m \cdot \left(\frac{l\_m}{Om\_m} \cdot 4\right)}{Om\_m} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
Om_m = (fabs.f64 Om)
(FPCore (l_m Om_m kx ky)
 :precision binary64
 (if (<= (/ (* 2.0 l_m) Om_m) 1e+115)
   (sqrt
    (+
     0.5
     (/
      0.5
      (sqrt
       (+
        1.0
        (*
         (/ (* l_m (* (/ l_m Om_m) 4.0)) Om_m)
         (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))
   (sqrt 0.5)))
l_m = fabs(l);
Om_m = fabs(Om);
double code(double l_m, double Om_m, double kx, double ky) {
	double tmp;
	if (((2.0 * l_m) / Om_m) <= 1e+115) {
		tmp = sqrt((0.5 + (0.5 / sqrt((1.0 + (((l_m * ((l_m / Om_m) * 4.0)) / Om_m) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0))))))));
	} else {
		tmp = sqrt(0.5);
	}
	return tmp;
}
l_m = abs(l)
Om_m = abs(om)
real(8) function code(l_m, om_m, kx, ky)
    real(8), intent (in) :: l_m
    real(8), intent (in) :: om_m
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: tmp
    if (((2.0d0 * l_m) / om_m) <= 1d+115) then
        tmp = sqrt((0.5d0 + (0.5d0 / sqrt((1.0d0 + (((l_m * ((l_m / om_m) * 4.0d0)) / om_m) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0))))))))
    else
        tmp = sqrt(0.5d0)
    end if
    code = tmp
end function
l_m = Math.abs(l);
Om_m = Math.abs(Om);
public static double code(double l_m, double Om_m, double kx, double ky) {
	double tmp;
	if (((2.0 * l_m) / Om_m) <= 1e+115) {
		tmp = Math.sqrt((0.5 + (0.5 / Math.sqrt((1.0 + (((l_m * ((l_m / Om_m) * 4.0)) / Om_m) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0))))))));
	} else {
		tmp = Math.sqrt(0.5);
	}
	return tmp;
}
l_m = math.fabs(l)
Om_m = math.fabs(Om)
def code(l_m, Om_m, kx, ky):
	tmp = 0
	if ((2.0 * l_m) / Om_m) <= 1e+115:
		tmp = math.sqrt((0.5 + (0.5 / math.sqrt((1.0 + (((l_m * ((l_m / Om_m) * 4.0)) / Om_m) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))))))))
	else:
		tmp = math.sqrt(0.5)
	return tmp
l_m = abs(l)
Om_m = abs(Om)
function code(l_m, Om_m, kx, ky)
	tmp = 0.0
	if (Float64(Float64(2.0 * l_m) / Om_m) <= 1e+115)
		tmp = sqrt(Float64(0.5 + Float64(0.5 / sqrt(Float64(1.0 + Float64(Float64(Float64(l_m * Float64(Float64(l_m / Om_m) * 4.0)) / Om_m) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))));
	else
		tmp = sqrt(0.5);
	end
	return tmp
end
l_m = abs(l);
Om_m = abs(Om);
function tmp_2 = code(l_m, Om_m, kx, ky)
	tmp = 0.0;
	if (((2.0 * l_m) / Om_m) <= 1e+115)
		tmp = sqrt((0.5 + (0.5 / sqrt((1.0 + (((l_m * ((l_m / Om_m) * 4.0)) / Om_m) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))));
	else
		tmp = sqrt(0.5);
	end
	tmp_2 = tmp;
end
l_m = N[Abs[l], $MachinePrecision]
Om_m = N[Abs[Om], $MachinePrecision]
code[l$95$m_, Om$95$m_, kx_, ky_] := If[LessEqual[N[(N[(2.0 * l$95$m), $MachinePrecision] / Om$95$m), $MachinePrecision], 1e+115], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[N[(1.0 + N[(N[(N[(l$95$m * N[(N[(l$95$m / Om$95$m), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] / Om$95$m), $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], N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
l_m = \left|\ell\right|
\\
Om_m = \left|Om\right|

\\
\begin{array}{l}
\mathbf{if}\;\frac{2 \cdot l\_m}{Om\_m} \leq 10^{+115}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{1 + \frac{l\_m \cdot \left(\frac{l\_m}{Om\_m} \cdot 4\right)}{Om\_m} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 #s(literal 2 binary64) l) Om) < 1e115

    1. Initial program 98.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. Step-by-step derivation
      1. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
    3. Simplified98.6%

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

    if 1e115 < (/.f64 (*.f64 #s(literal 2 binary64) l) Om)

    1. Initial program 90.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. Step-by-step derivation
      1. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
    3. Simplified90.9%

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{2}}} \]
    6. Step-by-step derivation
      1. sqrt-lowering-sqrt.f6498.2%

        \[\leadsto \mathsf{sqrt.f64}\left(\frac{1}{2}\right) \]
    7. Simplified98.2%

      \[\leadsto \color{blue}{\sqrt{0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 88.7% accurate, 1.0× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ \begin{array}{l} t_0 := \frac{Om\_m \cdot \frac{Om\_m}{l\_m \cdot 4}}{l\_m}\\ \mathbf{if}\;{\sin ky}^{2} \leq 5 \cdot 10^{-11}:\\ \;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{ky \cdot ky}{t\_0}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{{\left({\left(1 + \frac{\left(0.5 + -0.5 \cdot \cos \left(2 \cdot kx\right)\right) + \left(0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)\right)}{t\_0}\right)}^{0.25}\right)}^{2}}}\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
Om_m = (fabs.f64 Om)
(FPCore (l_m Om_m kx ky)
 :precision binary64
 (let* ((t_0 (/ (* Om_m (/ Om_m (* l_m 4.0))) l_m)))
   (if (<= (pow (sin ky) 2.0) 5e-11)
     (sqrt (- 0.5 (/ -0.5 (sqrt (+ 1.0 (/ (* ky ky) t_0))))))
     (sqrt
      (+
       0.5
       (/
        0.5
        (pow
         (pow
          (+
           1.0
           (/
            (+
             (+ 0.5 (* -0.5 (cos (* 2.0 kx))))
             (+ 0.5 (* -0.5 (cos (* 2.0 ky)))))
            t_0))
          0.25)
         2.0)))))))
l_m = fabs(l);
Om_m = fabs(Om);
double code(double l_m, double Om_m, double kx, double ky) {
	double t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	double tmp;
	if (pow(sin(ky), 2.0) <= 5e-11) {
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((ky * ky) / t_0))))));
	} else {
		tmp = sqrt((0.5 + (0.5 / pow(pow((1.0 + (((0.5 + (-0.5 * cos((2.0 * kx)))) + (0.5 + (-0.5 * cos((2.0 * ky))))) / t_0)), 0.25), 2.0))));
	}
	return tmp;
}
l_m = abs(l)
Om_m = abs(om)
real(8) function code(l_m, om_m, kx, ky)
    real(8), intent (in) :: l_m
    real(8), intent (in) :: om_m
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (om_m * (om_m / (l_m * 4.0d0))) / l_m
    if ((sin(ky) ** 2.0d0) <= 5d-11) then
        tmp = sqrt((0.5d0 - ((-0.5d0) / sqrt((1.0d0 + ((ky * ky) / t_0))))))
    else
        tmp = sqrt((0.5d0 + (0.5d0 / (((1.0d0 + (((0.5d0 + ((-0.5d0) * cos((2.0d0 * kx)))) + (0.5d0 + ((-0.5d0) * cos((2.0d0 * ky))))) / t_0)) ** 0.25d0) ** 2.0d0))))
    end if
    code = tmp
end function
l_m = Math.abs(l);
Om_m = Math.abs(Om);
public static double code(double l_m, double Om_m, double kx, double ky) {
	double t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	double tmp;
	if (Math.pow(Math.sin(ky), 2.0) <= 5e-11) {
		tmp = Math.sqrt((0.5 - (-0.5 / Math.sqrt((1.0 + ((ky * ky) / t_0))))));
	} else {
		tmp = Math.sqrt((0.5 + (0.5 / Math.pow(Math.pow((1.0 + (((0.5 + (-0.5 * Math.cos((2.0 * kx)))) + (0.5 + (-0.5 * Math.cos((2.0 * ky))))) / t_0)), 0.25), 2.0))));
	}
	return tmp;
}
l_m = math.fabs(l)
Om_m = math.fabs(Om)
def code(l_m, Om_m, kx, ky):
	t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m
	tmp = 0
	if math.pow(math.sin(ky), 2.0) <= 5e-11:
		tmp = math.sqrt((0.5 - (-0.5 / math.sqrt((1.0 + ((ky * ky) / t_0))))))
	else:
		tmp = math.sqrt((0.5 + (0.5 / math.pow(math.pow((1.0 + (((0.5 + (-0.5 * math.cos((2.0 * kx)))) + (0.5 + (-0.5 * math.cos((2.0 * ky))))) / t_0)), 0.25), 2.0))))
	return tmp
l_m = abs(l)
Om_m = abs(Om)
function code(l_m, Om_m, kx, ky)
	t_0 = Float64(Float64(Om_m * Float64(Om_m / Float64(l_m * 4.0))) / l_m)
	tmp = 0.0
	if ((sin(ky) ^ 2.0) <= 5e-11)
		tmp = sqrt(Float64(0.5 - Float64(-0.5 / sqrt(Float64(1.0 + Float64(Float64(ky * ky) / t_0))))));
	else
		tmp = sqrt(Float64(0.5 + Float64(0.5 / ((Float64(1.0 + Float64(Float64(Float64(0.5 + Float64(-0.5 * cos(Float64(2.0 * kx)))) + Float64(0.5 + Float64(-0.5 * cos(Float64(2.0 * ky))))) / t_0)) ^ 0.25) ^ 2.0))));
	end
	return tmp
end
l_m = abs(l);
Om_m = abs(Om);
function tmp_2 = code(l_m, Om_m, kx, ky)
	t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	tmp = 0.0;
	if ((sin(ky) ^ 2.0) <= 5e-11)
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((ky * ky) / t_0))))));
	else
		tmp = sqrt((0.5 + (0.5 / (((1.0 + (((0.5 + (-0.5 * cos((2.0 * kx)))) + (0.5 + (-0.5 * cos((2.0 * ky))))) / t_0)) ^ 0.25) ^ 2.0))));
	end
	tmp_2 = tmp;
end
l_m = N[Abs[l], $MachinePrecision]
Om_m = N[Abs[Om], $MachinePrecision]
code[l$95$m_, Om$95$m_, kx_, ky_] := Block[{t$95$0 = N[(N[(Om$95$m * N[(Om$95$m / N[(l$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision]}, If[LessEqual[N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision], 5e-11], N[Sqrt[N[(0.5 - N[(-0.5 / N[Sqrt[N[(1.0 + N[(N[(ky * ky), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Power[N[Power[N[(1.0 + N[(N[(N[(0.5 + N[(-0.5 * N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 + N[(-0.5 * N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
l_m = \left|\ell\right|
\\
Om_m = \left|Om\right|

\\
\begin{array}{l}
t_0 := \frac{Om\_m \cdot \frac{Om\_m}{l\_m \cdot 4}}{l\_m}\\
\mathbf{if}\;{\sin ky}^{2} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{ky \cdot ky}{t\_0}}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{{\left({\left(1 + \frac{\left(0.5 + -0.5 \cdot \cos \left(2 \cdot kx\right)\right) + \left(0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)\right)}{t\_0}\right)}^{0.25}\right)}^{2}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 (sin.f64 ky) #s(literal 2 binary64)) < 5.00000000000000018e-11

    1. Initial program 94.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. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
    3. Simplified94.2%

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6454.0%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified54.0%

      \[\leadsto \sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{\color{blue}{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}}{\frac{Om \cdot \frac{Om}{\ell \cdot 4}}{\ell}}}}} \]
    9. Taylor expanded in ky around 0

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left({ky}^{2}\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    10. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(ky \cdot ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f6471.7%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    11. Simplified71.7%

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

    if 5.00000000000000018e-11 < (pow.f64 (sin.f64 ky) #s(literal 2 binary64))

    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. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

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

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

      \[\leadsto \sqrt{0.5 + \frac{0.5}{\color{blue}{{\left({\left(1 + \frac{\left(0.5 + -0.5 \cdot \cos \left(2 \cdot kx\right)\right) + \left(0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)\right)}{\frac{Om \cdot \frac{Om}{\ell \cdot 4}}{\ell}}\right)}^{0.25}\right)}^{2}}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 88.7% accurate, 1.1× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ \begin{array}{l} t_0 := \frac{Om\_m \cdot \frac{Om\_m}{l\_m \cdot 4}}{l\_m}\\ \mathbf{if}\;{\sin ky}^{2} \leq 5 \cdot 10^{-11}:\\ \;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{ky \cdot ky}{t\_0}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{1 + -0.5 \cdot \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)}{t\_0}}}}\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
Om_m = (fabs.f64 Om)
(FPCore (l_m Om_m kx ky)
 :precision binary64
 (let* ((t_0 (/ (* Om_m (/ Om_m (* l_m 4.0))) l_m)))
   (if (<= (pow (sin ky) 2.0) 5e-11)
     (sqrt (- 0.5 (/ -0.5 (sqrt (+ 1.0 (/ (* ky ky) t_0))))))
     (sqrt
      (-
       0.5
       (/
        -0.5
        (sqrt
         (+
          1.0
          (/
           (+ 1.0 (* -0.5 (+ (cos (* 2.0 kx)) (cos (* 2.0 ky)))))
           t_0)))))))))
l_m = fabs(l);
Om_m = fabs(Om);
double code(double l_m, double Om_m, double kx, double ky) {
	double t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	double tmp;
	if (pow(sin(ky), 2.0) <= 5e-11) {
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((ky * ky) / t_0))))));
	} else {
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((1.0 + (-0.5 * (cos((2.0 * kx)) + cos((2.0 * ky))))) / t_0))))));
	}
	return tmp;
}
l_m = abs(l)
Om_m = abs(om)
real(8) function code(l_m, om_m, kx, ky)
    real(8), intent (in) :: l_m
    real(8), intent (in) :: om_m
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (om_m * (om_m / (l_m * 4.0d0))) / l_m
    if ((sin(ky) ** 2.0d0) <= 5d-11) then
        tmp = sqrt((0.5d0 - ((-0.5d0) / sqrt((1.0d0 + ((ky * ky) / t_0))))))
    else
        tmp = sqrt((0.5d0 - ((-0.5d0) / sqrt((1.0d0 + ((1.0d0 + ((-0.5d0) * (cos((2.0d0 * kx)) + cos((2.0d0 * ky))))) / t_0))))))
    end if
    code = tmp
end function
l_m = Math.abs(l);
Om_m = Math.abs(Om);
public static double code(double l_m, double Om_m, double kx, double ky) {
	double t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	double tmp;
	if (Math.pow(Math.sin(ky), 2.0) <= 5e-11) {
		tmp = Math.sqrt((0.5 - (-0.5 / Math.sqrt((1.0 + ((ky * ky) / t_0))))));
	} else {
		tmp = Math.sqrt((0.5 - (-0.5 / Math.sqrt((1.0 + ((1.0 + (-0.5 * (Math.cos((2.0 * kx)) + Math.cos((2.0 * ky))))) / t_0))))));
	}
	return tmp;
}
l_m = math.fabs(l)
Om_m = math.fabs(Om)
def code(l_m, Om_m, kx, ky):
	t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m
	tmp = 0
	if math.pow(math.sin(ky), 2.0) <= 5e-11:
		tmp = math.sqrt((0.5 - (-0.5 / math.sqrt((1.0 + ((ky * ky) / t_0))))))
	else:
		tmp = math.sqrt((0.5 - (-0.5 / math.sqrt((1.0 + ((1.0 + (-0.5 * (math.cos((2.0 * kx)) + math.cos((2.0 * ky))))) / t_0))))))
	return tmp
l_m = abs(l)
Om_m = abs(Om)
function code(l_m, Om_m, kx, ky)
	t_0 = Float64(Float64(Om_m * Float64(Om_m / Float64(l_m * 4.0))) / l_m)
	tmp = 0.0
	if ((sin(ky) ^ 2.0) <= 5e-11)
		tmp = sqrt(Float64(0.5 - Float64(-0.5 / sqrt(Float64(1.0 + Float64(Float64(ky * ky) / t_0))))));
	else
		tmp = sqrt(Float64(0.5 - Float64(-0.5 / sqrt(Float64(1.0 + Float64(Float64(1.0 + Float64(-0.5 * Float64(cos(Float64(2.0 * kx)) + cos(Float64(2.0 * ky))))) / t_0))))));
	end
	return tmp
end
l_m = abs(l);
Om_m = abs(Om);
function tmp_2 = code(l_m, Om_m, kx, ky)
	t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	tmp = 0.0;
	if ((sin(ky) ^ 2.0) <= 5e-11)
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((ky * ky) / t_0))))));
	else
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((1.0 + (-0.5 * (cos((2.0 * kx)) + cos((2.0 * ky))))) / t_0))))));
	end
	tmp_2 = tmp;
end
l_m = N[Abs[l], $MachinePrecision]
Om_m = N[Abs[Om], $MachinePrecision]
code[l$95$m_, Om$95$m_, kx_, ky_] := Block[{t$95$0 = N[(N[(Om$95$m * N[(Om$95$m / N[(l$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision]}, If[LessEqual[N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision], 5e-11], N[Sqrt[N[(0.5 - N[(-0.5 / N[Sqrt[N[(1.0 + N[(N[(ky * ky), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 - N[(-0.5 / N[Sqrt[N[(1.0 + N[(N[(1.0 + N[(-0.5 * N[(N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
l_m = \left|\ell\right|
\\
Om_m = \left|Om\right|

\\
\begin{array}{l}
t_0 := \frac{Om\_m \cdot \frac{Om\_m}{l\_m \cdot 4}}{l\_m}\\
\mathbf{if}\;{\sin ky}^{2} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{ky \cdot ky}{t\_0}}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{1 + -0.5 \cdot \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)}{t\_0}}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 (sin.f64 ky) #s(literal 2 binary64)) < 5.00000000000000018e-11

    1. Initial program 94.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. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
    3. Simplified94.2%

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6454.0%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified54.0%

      \[\leadsto \sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{\color{blue}{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}}{\frac{Om \cdot \frac{Om}{\ell \cdot 4}}{\ell}}}}} \]
    9. Taylor expanded in ky around 0

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left({ky}^{2}\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    10. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(ky \cdot ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f6471.7%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    11. Simplified71.7%

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

    if 5.00000000000000018e-11 < (pow.f64 (sin.f64 ky) #s(literal 2 binary64))

    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. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

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

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left(1 + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      2. distribute-lft-outN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-1}{2} \cdot \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{+.f64}\left(\cos \left(2 \cdot kx\right), \cos \left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      5. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(2 \cdot kx\right)\right), \cos \left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, kx\right)\right), \cos \left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      7. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, kx\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot ky\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f6499.3%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, kx\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, ky\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified99.3%

      \[\leadsto \sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{\color{blue}{1 + -0.5 \cdot \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)}}{\frac{Om \cdot \frac{Om}{\ell \cdot 4}}{\ell}}}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 88.3% accurate, 1.1× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ \begin{array}{l} t_0 := \frac{Om\_m \cdot \frac{Om\_m}{l\_m \cdot 4}}{l\_m}\\ \mathbf{if}\;{\sin ky}^{2} \leq 5 \cdot 10^{-11}:\\ \;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{ky \cdot ky}{t\_0}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{{\left({\left(1 + \frac{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}{t\_0}\right)}^{0.25}\right)}^{2}}}\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
Om_m = (fabs.f64 Om)
(FPCore (l_m Om_m kx ky)
 :precision binary64
 (let* ((t_0 (/ (* Om_m (/ Om_m (* l_m 4.0))) l_m)))
   (if (<= (pow (sin ky) 2.0) 5e-11)
     (sqrt (- 0.5 (/ -0.5 (sqrt (+ 1.0 (/ (* ky ky) t_0))))))
     (sqrt
      (+
       0.5
       (/
        0.5
        (pow
         (pow (+ 1.0 (/ (+ 0.5 (* -0.5 (cos (* 2.0 ky)))) t_0)) 0.25)
         2.0)))))))
l_m = fabs(l);
Om_m = fabs(Om);
double code(double l_m, double Om_m, double kx, double ky) {
	double t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	double tmp;
	if (pow(sin(ky), 2.0) <= 5e-11) {
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((ky * ky) / t_0))))));
	} else {
		tmp = sqrt((0.5 + (0.5 / pow(pow((1.0 + ((0.5 + (-0.5 * cos((2.0 * ky)))) / t_0)), 0.25), 2.0))));
	}
	return tmp;
}
l_m = abs(l)
Om_m = abs(om)
real(8) function code(l_m, om_m, kx, ky)
    real(8), intent (in) :: l_m
    real(8), intent (in) :: om_m
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (om_m * (om_m / (l_m * 4.0d0))) / l_m
    if ((sin(ky) ** 2.0d0) <= 5d-11) then
        tmp = sqrt((0.5d0 - ((-0.5d0) / sqrt((1.0d0 + ((ky * ky) / t_0))))))
    else
        tmp = sqrt((0.5d0 + (0.5d0 / (((1.0d0 + ((0.5d0 + ((-0.5d0) * cos((2.0d0 * ky)))) / t_0)) ** 0.25d0) ** 2.0d0))))
    end if
    code = tmp
end function
l_m = Math.abs(l);
Om_m = Math.abs(Om);
public static double code(double l_m, double Om_m, double kx, double ky) {
	double t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	double tmp;
	if (Math.pow(Math.sin(ky), 2.0) <= 5e-11) {
		tmp = Math.sqrt((0.5 - (-0.5 / Math.sqrt((1.0 + ((ky * ky) / t_0))))));
	} else {
		tmp = Math.sqrt((0.5 + (0.5 / Math.pow(Math.pow((1.0 + ((0.5 + (-0.5 * Math.cos((2.0 * ky)))) / t_0)), 0.25), 2.0))));
	}
	return tmp;
}
l_m = math.fabs(l)
Om_m = math.fabs(Om)
def code(l_m, Om_m, kx, ky):
	t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m
	tmp = 0
	if math.pow(math.sin(ky), 2.0) <= 5e-11:
		tmp = math.sqrt((0.5 - (-0.5 / math.sqrt((1.0 + ((ky * ky) / t_0))))))
	else:
		tmp = math.sqrt((0.5 + (0.5 / math.pow(math.pow((1.0 + ((0.5 + (-0.5 * math.cos((2.0 * ky)))) / t_0)), 0.25), 2.0))))
	return tmp
l_m = abs(l)
Om_m = abs(Om)
function code(l_m, Om_m, kx, ky)
	t_0 = Float64(Float64(Om_m * Float64(Om_m / Float64(l_m * 4.0))) / l_m)
	tmp = 0.0
	if ((sin(ky) ^ 2.0) <= 5e-11)
		tmp = sqrt(Float64(0.5 - Float64(-0.5 / sqrt(Float64(1.0 + Float64(Float64(ky * ky) / t_0))))));
	else
		tmp = sqrt(Float64(0.5 + Float64(0.5 / ((Float64(1.0 + Float64(Float64(0.5 + Float64(-0.5 * cos(Float64(2.0 * ky)))) / t_0)) ^ 0.25) ^ 2.0))));
	end
	return tmp
end
l_m = abs(l);
Om_m = abs(Om);
function tmp_2 = code(l_m, Om_m, kx, ky)
	t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	tmp = 0.0;
	if ((sin(ky) ^ 2.0) <= 5e-11)
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((ky * ky) / t_0))))));
	else
		tmp = sqrt((0.5 + (0.5 / (((1.0 + ((0.5 + (-0.5 * cos((2.0 * ky)))) / t_0)) ^ 0.25) ^ 2.0))));
	end
	tmp_2 = tmp;
end
l_m = N[Abs[l], $MachinePrecision]
Om_m = N[Abs[Om], $MachinePrecision]
code[l$95$m_, Om$95$m_, kx_, ky_] := Block[{t$95$0 = N[(N[(Om$95$m * N[(Om$95$m / N[(l$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision]}, If[LessEqual[N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision], 5e-11], N[Sqrt[N[(0.5 - N[(-0.5 / N[Sqrt[N[(1.0 + N[(N[(ky * ky), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Power[N[Power[N[(1.0 + N[(N[(0.5 + N[(-0.5 * N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
l_m = \left|\ell\right|
\\
Om_m = \left|Om\right|

\\
\begin{array}{l}
t_0 := \frac{Om\_m \cdot \frac{Om\_m}{l\_m \cdot 4}}{l\_m}\\
\mathbf{if}\;{\sin ky}^{2} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{ky \cdot ky}{t\_0}}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{{\left({\left(1 + \frac{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}{t\_0}\right)}^{0.25}\right)}^{2}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 (sin.f64 ky) #s(literal 2 binary64)) < 5.00000000000000018e-11

    1. Initial program 94.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. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
    3. Simplified94.2%

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6454.0%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified54.0%

      \[\leadsto \sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{\color{blue}{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}}{\frac{Om \cdot \frac{Om}{\ell \cdot 4}}{\ell}}}}} \]
    9. Taylor expanded in ky around 0

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left({ky}^{2}\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    10. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(ky \cdot ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f6471.7%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    11. Simplified71.7%

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

    if 5.00000000000000018e-11 < (pow.f64 (sin.f64 ky) #s(literal 2 binary64))

    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. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

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

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right), \frac{1}{4}\right), 2\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right), \frac{1}{4}\right), 2\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right), \frac{1}{4}\right), 2\right)\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right), \frac{1}{4}\right), 2\right)\right)\right)\right) \]
      4. *-lowering-*.f6498.8%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right), \frac{1}{4}\right), 2\right)\right)\right)\right) \]
    8. Simplified98.8%

      \[\leadsto \sqrt{0.5 + \frac{0.5}{{\left({\left(1 + \frac{\color{blue}{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}}{\frac{Om \cdot \frac{Om}{\ell \cdot 4}}{\ell}}\right)}^{0.25}\right)}^{2}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 88.3% accurate, 1.4× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ \begin{array}{l} t_0 := \frac{Om\_m \cdot \frac{Om\_m}{l\_m \cdot 4}}{l\_m}\\ \mathbf{if}\;{\sin ky}^{2} \leq 5 \cdot 10^{-11}:\\ \;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{ky \cdot ky}{t\_0}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}{t\_0}}}}\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
Om_m = (fabs.f64 Om)
(FPCore (l_m Om_m kx ky)
 :precision binary64
 (let* ((t_0 (/ (* Om_m (/ Om_m (* l_m 4.0))) l_m)))
   (if (<= (pow (sin ky) 2.0) 5e-11)
     (sqrt (- 0.5 (/ -0.5 (sqrt (+ 1.0 (/ (* ky ky) t_0))))))
     (sqrt
      (-
       0.5
       (/ -0.5 (sqrt (+ 1.0 (/ (+ 0.5 (* -0.5 (cos (* 2.0 ky)))) t_0)))))))))
l_m = fabs(l);
Om_m = fabs(Om);
double code(double l_m, double Om_m, double kx, double ky) {
	double t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	double tmp;
	if (pow(sin(ky), 2.0) <= 5e-11) {
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((ky * ky) / t_0))))));
	} else {
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((0.5 + (-0.5 * cos((2.0 * ky)))) / t_0))))));
	}
	return tmp;
}
l_m = abs(l)
Om_m = abs(om)
real(8) function code(l_m, om_m, kx, ky)
    real(8), intent (in) :: l_m
    real(8), intent (in) :: om_m
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (om_m * (om_m / (l_m * 4.0d0))) / l_m
    if ((sin(ky) ** 2.0d0) <= 5d-11) then
        tmp = sqrt((0.5d0 - ((-0.5d0) / sqrt((1.0d0 + ((ky * ky) / t_0))))))
    else
        tmp = sqrt((0.5d0 - ((-0.5d0) / sqrt((1.0d0 + ((0.5d0 + ((-0.5d0) * cos((2.0d0 * ky)))) / t_0))))))
    end if
    code = tmp
end function
l_m = Math.abs(l);
Om_m = Math.abs(Om);
public static double code(double l_m, double Om_m, double kx, double ky) {
	double t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	double tmp;
	if (Math.pow(Math.sin(ky), 2.0) <= 5e-11) {
		tmp = Math.sqrt((0.5 - (-0.5 / Math.sqrt((1.0 + ((ky * ky) / t_0))))));
	} else {
		tmp = Math.sqrt((0.5 - (-0.5 / Math.sqrt((1.0 + ((0.5 + (-0.5 * Math.cos((2.0 * ky)))) / t_0))))));
	}
	return tmp;
}
l_m = math.fabs(l)
Om_m = math.fabs(Om)
def code(l_m, Om_m, kx, ky):
	t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m
	tmp = 0
	if math.pow(math.sin(ky), 2.0) <= 5e-11:
		tmp = math.sqrt((0.5 - (-0.5 / math.sqrt((1.0 + ((ky * ky) / t_0))))))
	else:
		tmp = math.sqrt((0.5 - (-0.5 / math.sqrt((1.0 + ((0.5 + (-0.5 * math.cos((2.0 * ky)))) / t_0))))))
	return tmp
l_m = abs(l)
Om_m = abs(Om)
function code(l_m, Om_m, kx, ky)
	t_0 = Float64(Float64(Om_m * Float64(Om_m / Float64(l_m * 4.0))) / l_m)
	tmp = 0.0
	if ((sin(ky) ^ 2.0) <= 5e-11)
		tmp = sqrt(Float64(0.5 - Float64(-0.5 / sqrt(Float64(1.0 + Float64(Float64(ky * ky) / t_0))))));
	else
		tmp = sqrt(Float64(0.5 - Float64(-0.5 / sqrt(Float64(1.0 + Float64(Float64(0.5 + Float64(-0.5 * cos(Float64(2.0 * ky)))) / t_0))))));
	end
	return tmp
end
l_m = abs(l);
Om_m = abs(Om);
function tmp_2 = code(l_m, Om_m, kx, ky)
	t_0 = (Om_m * (Om_m / (l_m * 4.0))) / l_m;
	tmp = 0.0;
	if ((sin(ky) ^ 2.0) <= 5e-11)
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((ky * ky) / t_0))))));
	else
		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((0.5 + (-0.5 * cos((2.0 * ky)))) / t_0))))));
	end
	tmp_2 = tmp;
end
l_m = N[Abs[l], $MachinePrecision]
Om_m = N[Abs[Om], $MachinePrecision]
code[l$95$m_, Om$95$m_, kx_, ky_] := Block[{t$95$0 = N[(N[(Om$95$m * N[(Om$95$m / N[(l$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision]}, If[LessEqual[N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision], 5e-11], N[Sqrt[N[(0.5 - N[(-0.5 / N[Sqrt[N[(1.0 + N[(N[(ky * ky), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 - N[(-0.5 / N[Sqrt[N[(1.0 + N[(N[(0.5 + N[(-0.5 * N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
l_m = \left|\ell\right|
\\
Om_m = \left|Om\right|

\\
\begin{array}{l}
t_0 := \frac{Om\_m \cdot \frac{Om\_m}{l\_m \cdot 4}}{l\_m}\\
\mathbf{if}\;{\sin ky}^{2} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{ky \cdot ky}{t\_0}}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}{t\_0}}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 (sin.f64 ky) #s(literal 2 binary64)) < 5.00000000000000018e-11

    1. Initial program 94.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. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
    3. Simplified94.2%

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6454.0%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified54.0%

      \[\leadsto \sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{\color{blue}{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}}{\frac{Om \cdot \frac{Om}{\ell \cdot 4}}{\ell}}}}} \]
    9. Taylor expanded in ky around 0

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left({ky}^{2}\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    10. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(ky \cdot ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f6471.7%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    11. Simplified71.7%

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

    if 5.00000000000000018e-11 < (pow.f64 (sin.f64 ky) #s(literal 2 binary64))

    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. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

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

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6498.8%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified98.8%

      \[\leadsto \sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{\color{blue}{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}}{\frac{Om \cdot \frac{Om}{\ell \cdot 4}}{\ell}}}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 81.8% accurate, 3.2× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ \begin{array}{l} \mathbf{if}\;l\_m \leq 8.5 \cdot 10^{-83}:\\ \;\;\;\;1\\ \mathbf{elif}\;l\_m \leq 1.6 \cdot 10^{+135}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{1 + \left(4 \cdot \left(l\_m \cdot l\_m\right)\right) \cdot \frac{ky \cdot ky}{Om\_m \cdot Om\_m}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
Om_m = (fabs.f64 Om)
(FPCore (l_m Om_m kx ky)
 :precision binary64
 (if (<= l_m 8.5e-83)
   1.0
   (if (<= l_m 1.6e+135)
     (sqrt
      (+
       0.5
       (/
        0.5
        (sqrt (+ 1.0 (* (* 4.0 (* l_m l_m)) (/ (* ky ky) (* Om_m Om_m))))))))
     (sqrt 0.5))))
l_m = fabs(l);
Om_m = fabs(Om);
double code(double l_m, double Om_m, double kx, double ky) {
	double tmp;
	if (l_m <= 8.5e-83) {
		tmp = 1.0;
	} else if (l_m <= 1.6e+135) {
		tmp = sqrt((0.5 + (0.5 / sqrt((1.0 + ((4.0 * (l_m * l_m)) * ((ky * ky) / (Om_m * Om_m))))))));
	} else {
		tmp = sqrt(0.5);
	}
	return tmp;
}
l_m = abs(l)
Om_m = abs(om)
real(8) function code(l_m, om_m, kx, ky)
    real(8), intent (in) :: l_m
    real(8), intent (in) :: om_m
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: tmp
    if (l_m <= 8.5d-83) then
        tmp = 1.0d0
    else if (l_m <= 1.6d+135) then
        tmp = sqrt((0.5d0 + (0.5d0 / sqrt((1.0d0 + ((4.0d0 * (l_m * l_m)) * ((ky * ky) / (om_m * om_m))))))))
    else
        tmp = sqrt(0.5d0)
    end if
    code = tmp
end function
l_m = Math.abs(l);
Om_m = Math.abs(Om);
public static double code(double l_m, double Om_m, double kx, double ky) {
	double tmp;
	if (l_m <= 8.5e-83) {
		tmp = 1.0;
	} else if (l_m <= 1.6e+135) {
		tmp = Math.sqrt((0.5 + (0.5 / Math.sqrt((1.0 + ((4.0 * (l_m * l_m)) * ((ky * ky) / (Om_m * Om_m))))))));
	} else {
		tmp = Math.sqrt(0.5);
	}
	return tmp;
}
l_m = math.fabs(l)
Om_m = math.fabs(Om)
def code(l_m, Om_m, kx, ky):
	tmp = 0
	if l_m <= 8.5e-83:
		tmp = 1.0
	elif l_m <= 1.6e+135:
		tmp = math.sqrt((0.5 + (0.5 / math.sqrt((1.0 + ((4.0 * (l_m * l_m)) * ((ky * ky) / (Om_m * Om_m))))))))
	else:
		tmp = math.sqrt(0.5)
	return tmp
l_m = abs(l)
Om_m = abs(Om)
function code(l_m, Om_m, kx, ky)
	tmp = 0.0
	if (l_m <= 8.5e-83)
		tmp = 1.0;
	elseif (l_m <= 1.6e+135)
		tmp = sqrt(Float64(0.5 + Float64(0.5 / sqrt(Float64(1.0 + Float64(Float64(4.0 * Float64(l_m * l_m)) * Float64(Float64(ky * ky) / Float64(Om_m * Om_m))))))));
	else
		tmp = sqrt(0.5);
	end
	return tmp
end
l_m = abs(l);
Om_m = abs(Om);
function tmp_2 = code(l_m, Om_m, kx, ky)
	tmp = 0.0;
	if (l_m <= 8.5e-83)
		tmp = 1.0;
	elseif (l_m <= 1.6e+135)
		tmp = sqrt((0.5 + (0.5 / sqrt((1.0 + ((4.0 * (l_m * l_m)) * ((ky * ky) / (Om_m * Om_m))))))));
	else
		tmp = sqrt(0.5);
	end
	tmp_2 = tmp;
end
l_m = N[Abs[l], $MachinePrecision]
Om_m = N[Abs[Om], $MachinePrecision]
code[l$95$m_, Om$95$m_, kx_, ky_] := If[LessEqual[l$95$m, 8.5e-83], 1.0, If[LessEqual[l$95$m, 1.6e+135], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[N[(1.0 + N[(N[(4.0 * N[(l$95$m * l$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] / N[(Om$95$m * Om$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]
\begin{array}{l}
l_m = \left|\ell\right|
\\
Om_m = \left|Om\right|

\\
\begin{array}{l}
\mathbf{if}\;l\_m \leq 8.5 \cdot 10^{-83}:\\
\;\;\;\;1\\

\mathbf{elif}\;l\_m \leq 1.6 \cdot 10^{+135}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{1 + \left(4 \cdot \left(l\_m \cdot l\_m\right)\right) \cdot \frac{ky \cdot ky}{Om\_m \cdot Om\_m}}}}\\

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


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

    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. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      10. metadata-evalN/A

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

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

      \[\leadsto \color{blue}{1} \]
    6. Step-by-step derivation
      1. Simplified68.4%

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

      if 8.49999999999999938e-83 < l < 1.59999999999999987e135

      1. Initial program 97.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. sqrt-lowering-sqrt.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
        2. *-commutativeN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
        3. +-commutativeN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
        4. distribute-rgt1-inN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
        6. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
        7. associate-*l/N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
        8. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
        9. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
        10. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      3. Simplified97.8%

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{1 + 4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}\right)}\right)\right)\right) \]
      6. Step-by-step derivation
        1. sqrt-lowering-sqrt.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\left(1 + 4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right) \]
        2. +-lowering-+.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
        3. associate-/l*N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(4 \cdot \left({\ell}^{2} \cdot \frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
        4. associate-*r*N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(\left(4 \cdot {\ell}^{2}\right) \cdot \frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
        5. *-lowering-*.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(4 \cdot {\ell}^{2}\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
        6. *-lowering-*.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \left({\ell}^{2}\right)\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
        7. unpow2N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \left(\ell \cdot \ell\right)\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
        8. *-lowering-*.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
        9. /-lowering-/.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\left({\sin ky}^{2}\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
        10. pow-lowering-pow.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\sin ky, 2\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
        11. sin-lowering-sin.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
        12. unpow2N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right), \left(Om \cdot Om\right)\right)\right)\right)\right)\right)\right)\right) \]
        13. *-lowering-*.f6484.2%

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right), \mathsf{*.f64}\left(Om, Om\right)\right)\right)\right)\right)\right)\right)\right) \]
      7. Simplified84.2%

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \color{blue}{\left(\frac{{ky}^{2}}{{Om}^{2}}\right)}\right)\right)\right)\right)\right)\right) \]
      9. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\left({ky}^{2}\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
        2. unpow2N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\left(ky \cdot ky\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
        4. unpow2N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \left(Om \cdot Om\right)\right)\right)\right)\right)\right)\right)\right) \]
        5. *-lowering-*.f6472.0%

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{*.f64}\left(Om, Om\right)\right)\right)\right)\right)\right)\right)\right) \]
      10. Simplified72.0%

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

      if 1.59999999999999987e135 < l

      1. Initial program 94.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. sqrt-lowering-sqrt.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
        2. *-commutativeN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
        3. +-commutativeN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
        4. distribute-rgt1-inN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
        6. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
        7. associate-*l/N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
        8. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
        9. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
        10. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
      3. Simplified94.7%

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{2}}} \]
      6. Step-by-step derivation
        1. sqrt-lowering-sqrt.f6493.7%

          \[\leadsto \mathsf{sqrt.f64}\left(\frac{1}{2}\right) \]
      7. Simplified93.7%

        \[\leadsto \color{blue}{\sqrt{0.5}} \]
    7. Recombined 3 regimes into one program.
    8. Add Preprocessing

    Alternative 7: 79.3% accurate, 3.2× speedup?

    \[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ \begin{array}{l} \mathbf{if}\;l\_m \leq 1.6 \cdot 10^{-82}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{ky \cdot ky}{\frac{Om\_m \cdot \frac{Om\_m}{l\_m \cdot 4}}{l\_m}}}}}\\ \end{array} \end{array} \]
    l_m = (fabs.f64 l)
    Om_m = (fabs.f64 Om)
    (FPCore (l_m Om_m kx ky)
     :precision binary64
     (if (<= l_m 1.6e-82)
       1.0
       (sqrt
        (-
         0.5
         (/
          -0.5
          (sqrt (+ 1.0 (/ (* ky ky) (/ (* Om_m (/ Om_m (* l_m 4.0))) l_m)))))))))
    l_m = fabs(l);
    Om_m = fabs(Om);
    double code(double l_m, double Om_m, double kx, double ky) {
    	double tmp;
    	if (l_m <= 1.6e-82) {
    		tmp = 1.0;
    	} else {
    		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((ky * ky) / ((Om_m * (Om_m / (l_m * 4.0))) / l_m)))))));
    	}
    	return tmp;
    }
    
    l_m = abs(l)
    Om_m = abs(om)
    real(8) function code(l_m, om_m, kx, ky)
        real(8), intent (in) :: l_m
        real(8), intent (in) :: om_m
        real(8), intent (in) :: kx
        real(8), intent (in) :: ky
        real(8) :: tmp
        if (l_m <= 1.6d-82) then
            tmp = 1.0d0
        else
            tmp = sqrt((0.5d0 - ((-0.5d0) / sqrt((1.0d0 + ((ky * ky) / ((om_m * (om_m / (l_m * 4.0d0))) / l_m)))))))
        end if
        code = tmp
    end function
    
    l_m = Math.abs(l);
    Om_m = Math.abs(Om);
    public static double code(double l_m, double Om_m, double kx, double ky) {
    	double tmp;
    	if (l_m <= 1.6e-82) {
    		tmp = 1.0;
    	} else {
    		tmp = Math.sqrt((0.5 - (-0.5 / Math.sqrt((1.0 + ((ky * ky) / ((Om_m * (Om_m / (l_m * 4.0))) / l_m)))))));
    	}
    	return tmp;
    }
    
    l_m = math.fabs(l)
    Om_m = math.fabs(Om)
    def code(l_m, Om_m, kx, ky):
    	tmp = 0
    	if l_m <= 1.6e-82:
    		tmp = 1.0
    	else:
    		tmp = math.sqrt((0.5 - (-0.5 / math.sqrt((1.0 + ((ky * ky) / ((Om_m * (Om_m / (l_m * 4.0))) / l_m)))))))
    	return tmp
    
    l_m = abs(l)
    Om_m = abs(Om)
    function code(l_m, Om_m, kx, ky)
    	tmp = 0.0
    	if (l_m <= 1.6e-82)
    		tmp = 1.0;
    	else
    		tmp = sqrt(Float64(0.5 - Float64(-0.5 / sqrt(Float64(1.0 + Float64(Float64(ky * ky) / Float64(Float64(Om_m * Float64(Om_m / Float64(l_m * 4.0))) / l_m)))))));
    	end
    	return tmp
    end
    
    l_m = abs(l);
    Om_m = abs(Om);
    function tmp_2 = code(l_m, Om_m, kx, ky)
    	tmp = 0.0;
    	if (l_m <= 1.6e-82)
    		tmp = 1.0;
    	else
    		tmp = sqrt((0.5 - (-0.5 / sqrt((1.0 + ((ky * ky) / ((Om_m * (Om_m / (l_m * 4.0))) / l_m)))))));
    	end
    	tmp_2 = tmp;
    end
    
    l_m = N[Abs[l], $MachinePrecision]
    Om_m = N[Abs[Om], $MachinePrecision]
    code[l$95$m_, Om$95$m_, kx_, ky_] := If[LessEqual[l$95$m, 1.6e-82], 1.0, N[Sqrt[N[(0.5 - N[(-0.5 / N[Sqrt[N[(1.0 + N[(N[(ky * ky), $MachinePrecision] / N[(N[(Om$95$m * N[(Om$95$m / N[(l$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
    
    \begin{array}{l}
    l_m = \left|\ell\right|
    \\
    Om_m = \left|Om\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;l\_m \leq 1.6 \cdot 10^{-82}:\\
    \;\;\;\;1\\
    
    \mathbf{else}:\\
    \;\;\;\;\sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{ky \cdot ky}{\frac{Om\_m \cdot \frac{Om\_m}{l\_m \cdot 4}}{l\_m}}}}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if l < 1.6000000000000001e-82

      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. sqrt-lowering-sqrt.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
        2. *-commutativeN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
        3. +-commutativeN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
        4. distribute-rgt1-inN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
        6. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
        7. associate-*l/N/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
        8. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
        9. metadata-evalN/A

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
        10. metadata-evalN/A

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

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

        \[\leadsto \color{blue}{1} \]
      6. Step-by-step derivation
        1. Simplified68.4%

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

        if 1.6000000000000001e-82 < l

        1. Initial program 96.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. sqrt-lowering-sqrt.f64N/A

            \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
          2. *-commutativeN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
          3. +-commutativeN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
          4. distribute-rgt1-inN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
          5. +-lowering-+.f64N/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
          6. metadata-evalN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
          7. associate-*l/N/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
          8. metadata-evalN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
          9. metadata-evalN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
          10. metadata-evalN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
        3. Simplified96.4%

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

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

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
        7. Step-by-step derivation
          1. +-lowering-+.f64N/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
          2. *-lowering-*.f64N/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \cos \left(2 \cdot ky\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
          3. cos-lowering-cos.f64N/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\left(2 \cdot ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
          4. *-lowering-*.f6464.3%

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, ky\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
        8. Simplified64.3%

          \[\leadsto \sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{\color{blue}{0.5 + -0.5 \cdot \cos \left(2 \cdot ky\right)}}{\frac{Om \cdot \frac{Om}{\ell \cdot 4}}{\ell}}}}} \]
        9. Taylor expanded in ky around 0

          \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\color{blue}{\left({ky}^{2}\right)}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
        10. Step-by-step derivation
          1. unpow2N/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(ky \cdot ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
          2. *-lowering-*.f6465.8%

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{-1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(Om, \mathsf{/.f64}\left(Om, \mathsf{*.f64}\left(\ell, 4\right)\right)\right), \ell\right)\right)\right)\right)\right)\right)\right) \]
        11. Simplified65.8%

          \[\leadsto \sqrt{0.5 - \frac{-0.5}{\sqrt{1 + \frac{\color{blue}{ky \cdot ky}}{\frac{Om \cdot \frac{Om}{\ell \cdot 4}}{\ell}}}}} \]
      7. Recombined 2 regimes into one program.
      8. Add Preprocessing

      Alternative 8: 81.7% accurate, 5.4× speedup?

      \[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ \begin{array}{l} \mathbf{if}\;l\_m \leq 1.4 \cdot 10^{-82}:\\ \;\;\;\;1\\ \mathbf{elif}\;l\_m \leq 1.35 \cdot 10^{+135}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{\left(l\_m \cdot l\_m\right) \cdot \left(\frac{1}{l\_m \cdot l\_m} + \frac{2 \cdot \left(ky \cdot ky\right)}{Om\_m \cdot Om\_m}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
      l_m = (fabs.f64 l)
      Om_m = (fabs.f64 Om)
      (FPCore (l_m Om_m kx ky)
       :precision binary64
       (if (<= l_m 1.4e-82)
         1.0
         (if (<= l_m 1.35e+135)
           (sqrt
            (+
             0.5
             (/
              0.5
              (*
               (* l_m l_m)
               (+ (/ 1.0 (* l_m l_m)) (/ (* 2.0 (* ky ky)) (* Om_m Om_m)))))))
           (sqrt 0.5))))
      l_m = fabs(l);
      Om_m = fabs(Om);
      double code(double l_m, double Om_m, double kx, double ky) {
      	double tmp;
      	if (l_m <= 1.4e-82) {
      		tmp = 1.0;
      	} else if (l_m <= 1.35e+135) {
      		tmp = sqrt((0.5 + (0.5 / ((l_m * l_m) * ((1.0 / (l_m * l_m)) + ((2.0 * (ky * ky)) / (Om_m * Om_m)))))));
      	} else {
      		tmp = sqrt(0.5);
      	}
      	return tmp;
      }
      
      l_m = abs(l)
      Om_m = abs(om)
      real(8) function code(l_m, om_m, kx, ky)
          real(8), intent (in) :: l_m
          real(8), intent (in) :: om_m
          real(8), intent (in) :: kx
          real(8), intent (in) :: ky
          real(8) :: tmp
          if (l_m <= 1.4d-82) then
              tmp = 1.0d0
          else if (l_m <= 1.35d+135) then
              tmp = sqrt((0.5d0 + (0.5d0 / ((l_m * l_m) * ((1.0d0 / (l_m * l_m)) + ((2.0d0 * (ky * ky)) / (om_m * om_m)))))))
          else
              tmp = sqrt(0.5d0)
          end if
          code = tmp
      end function
      
      l_m = Math.abs(l);
      Om_m = Math.abs(Om);
      public static double code(double l_m, double Om_m, double kx, double ky) {
      	double tmp;
      	if (l_m <= 1.4e-82) {
      		tmp = 1.0;
      	} else if (l_m <= 1.35e+135) {
      		tmp = Math.sqrt((0.5 + (0.5 / ((l_m * l_m) * ((1.0 / (l_m * l_m)) + ((2.0 * (ky * ky)) / (Om_m * Om_m)))))));
      	} else {
      		tmp = Math.sqrt(0.5);
      	}
      	return tmp;
      }
      
      l_m = math.fabs(l)
      Om_m = math.fabs(Om)
      def code(l_m, Om_m, kx, ky):
      	tmp = 0
      	if l_m <= 1.4e-82:
      		tmp = 1.0
      	elif l_m <= 1.35e+135:
      		tmp = math.sqrt((0.5 + (0.5 / ((l_m * l_m) * ((1.0 / (l_m * l_m)) + ((2.0 * (ky * ky)) / (Om_m * Om_m)))))))
      	else:
      		tmp = math.sqrt(0.5)
      	return tmp
      
      l_m = abs(l)
      Om_m = abs(Om)
      function code(l_m, Om_m, kx, ky)
      	tmp = 0.0
      	if (l_m <= 1.4e-82)
      		tmp = 1.0;
      	elseif (l_m <= 1.35e+135)
      		tmp = sqrt(Float64(0.5 + Float64(0.5 / Float64(Float64(l_m * l_m) * Float64(Float64(1.0 / Float64(l_m * l_m)) + Float64(Float64(2.0 * Float64(ky * ky)) / Float64(Om_m * Om_m)))))));
      	else
      		tmp = sqrt(0.5);
      	end
      	return tmp
      end
      
      l_m = abs(l);
      Om_m = abs(Om);
      function tmp_2 = code(l_m, Om_m, kx, ky)
      	tmp = 0.0;
      	if (l_m <= 1.4e-82)
      		tmp = 1.0;
      	elseif (l_m <= 1.35e+135)
      		tmp = sqrt((0.5 + (0.5 / ((l_m * l_m) * ((1.0 / (l_m * l_m)) + ((2.0 * (ky * ky)) / (Om_m * Om_m)))))));
      	else
      		tmp = sqrt(0.5);
      	end
      	tmp_2 = tmp;
      end
      
      l_m = N[Abs[l], $MachinePrecision]
      Om_m = N[Abs[Om], $MachinePrecision]
      code[l$95$m_, Om$95$m_, kx_, ky_] := If[LessEqual[l$95$m, 1.4e-82], 1.0, If[LessEqual[l$95$m, 1.35e+135], N[Sqrt[N[(0.5 + N[(0.5 / N[(N[(l$95$m * l$95$m), $MachinePrecision] * N[(N[(1.0 / N[(l$95$m * l$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] / N[(Om$95$m * Om$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]
      
      \begin{array}{l}
      l_m = \left|\ell\right|
      \\
      Om_m = \left|Om\right|
      
      \\
      \begin{array}{l}
      \mathbf{if}\;l\_m \leq 1.4 \cdot 10^{-82}:\\
      \;\;\;\;1\\
      
      \mathbf{elif}\;l\_m \leq 1.35 \cdot 10^{+135}:\\
      \;\;\;\;\sqrt{0.5 + \frac{0.5}{\left(l\_m \cdot l\_m\right) \cdot \left(\frac{1}{l\_m \cdot l\_m} + \frac{2 \cdot \left(ky \cdot ky\right)}{Om\_m \cdot Om\_m}\right)}}\\
      
      \mathbf{else}:\\
      \;\;\;\;\sqrt{0.5}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if l < 1.40000000000000012e-82

        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. sqrt-lowering-sqrt.f64N/A

            \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
          2. *-commutativeN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
          3. +-commutativeN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
          4. distribute-rgt1-inN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
          5. +-lowering-+.f64N/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
          6. metadata-evalN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
          7. associate-*l/N/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
          8. metadata-evalN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
          9. metadata-evalN/A

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
          10. metadata-evalN/A

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

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

          \[\leadsto \color{blue}{1} \]
        6. Step-by-step derivation
          1. Simplified68.4%

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

          if 1.40000000000000012e-82 < l < 1.34999999999999992e135

          1. Initial program 97.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. sqrt-lowering-sqrt.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
            2. *-commutativeN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
            3. +-commutativeN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
            4. distribute-rgt1-inN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
            6. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
            7. associate-*l/N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            8. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            9. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            10. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
          3. Simplified97.8%

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

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{1 + 4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}\right)}\right)\right)\right) \]
          6. Step-by-step derivation
            1. sqrt-lowering-sqrt.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\left(1 + 4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right) \]
            2. +-lowering-+.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
            3. associate-/l*N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(4 \cdot \left({\ell}^{2} \cdot \frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
            4. associate-*r*N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(\left(4 \cdot {\ell}^{2}\right) \cdot \frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
            5. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(4 \cdot {\ell}^{2}\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
            6. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \left({\ell}^{2}\right)\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
            7. unpow2N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \left(\ell \cdot \ell\right)\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
            8. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
            9. /-lowering-/.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\left({\sin ky}^{2}\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
            10. pow-lowering-pow.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\sin ky, 2\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
            11. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
            12. unpow2N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right), \left(Om \cdot Om\right)\right)\right)\right)\right)\right)\right)\right) \]
            13. *-lowering-*.f6484.2%

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right), \mathsf{*.f64}\left(Om, Om\right)\right)\right)\right)\right)\right)\right)\right) \]
          7. Simplified84.2%

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

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(1 + 2 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}\right)}\right)\right)\right) \]
          9. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \left(2 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right) \]
            2. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \left(\frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
            3. /-lowering-/.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\left({ky}^{2} \cdot {\ell}^{2}\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({ky}^{2}\right), \left({\ell}^{2}\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
            5. unpow2N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(ky \cdot ky\right), \left({\ell}^{2}\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
            6. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \left({\ell}^{2}\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
            7. unpow2N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \left(\ell \cdot \ell\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
            8. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{*.f64}\left(\ell, \ell\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
            9. unpow2N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{*.f64}\left(\ell, \ell\right)\right), \left(Om \cdot Om\right)\right)\right)\right)\right)\right)\right) \]
            10. *-lowering-*.f6470.6%

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{*.f64}\left(Om, Om\right)\right)\right)\right)\right)\right)\right) \]
          10. Simplified70.6%

            \[\leadsto \sqrt{0.5 + \frac{0.5}{\color{blue}{1 + 2 \cdot \frac{\left(ky \cdot ky\right) \cdot \left(\ell \cdot \ell\right)}{Om \cdot Om}}}} \]
          11. Taylor expanded in l around inf

            \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left({\ell}^{2} \cdot \left(2 \cdot \frac{{ky}^{2}}{{Om}^{2}} + \frac{1}{{\ell}^{2}}\right)\right)}\right)\right)\right) \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \left(2 \cdot \frac{{ky}^{2}}{{Om}^{2}} + \frac{1}{{\ell}^{2}}\right)\right)\right)\right)\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \left(2 \cdot \frac{{ky}^{2}}{{Om}^{2}} + \frac{1}{{\ell}^{2}}\right)\right)\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \left(2 \cdot \frac{{ky}^{2}}{{Om}^{2}} + \frac{1}{{\ell}^{2}}\right)\right)\right)\right)\right) \]
            4. +-commutativeN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \left(\frac{1}{{\ell}^{2}} + 2 \cdot \frac{{ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\left(\frac{1}{{\ell}^{2}}\right), \left(2 \cdot \frac{{ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
            6. /-lowering-/.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, \left({\ell}^{2}\right)\right), \left(2 \cdot \frac{{ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
            7. unpow2N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, \left(\ell \cdot \ell\right)\right), \left(2 \cdot \frac{{ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
            8. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\ell, \ell\right)\right), \left(2 \cdot \frac{{ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
            9. associate-*r/N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\ell, \ell\right)\right), \left(\frac{2 \cdot {ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
            10. /-lowering-/.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\left(2 \cdot {ky}^{2}\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
            11. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(2, \left({ky}^{2}\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
            12. unpow2N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(2, \left(ky \cdot ky\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
            13. *-lowering-*.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(ky, ky\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
            14. unpow2N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(ky, ky\right)\right), \left(Om \cdot Om\right)\right)\right)\right)\right)\right)\right) \]
            15. *-lowering-*.f6472.7%

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(ky, ky\right)\right), \mathsf{*.f64}\left(Om, Om\right)\right)\right)\right)\right)\right)\right) \]
          13. Simplified72.7%

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

          if 1.34999999999999992e135 < l

          1. Initial program 94.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. sqrt-lowering-sqrt.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
            2. *-commutativeN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
            3. +-commutativeN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
            4. distribute-rgt1-inN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
            6. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
            7. associate-*l/N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            8. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            9. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            10. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
          3. Simplified94.7%

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

            \[\leadsto \color{blue}{\sqrt{\frac{1}{2}}} \]
          6. Step-by-step derivation
            1. sqrt-lowering-sqrt.f6493.7%

              \[\leadsto \mathsf{sqrt.f64}\left(\frac{1}{2}\right) \]
          7. Simplified93.7%

            \[\leadsto \color{blue}{\sqrt{0.5}} \]
        7. Recombined 3 regimes into one program.
        8. Add Preprocessing

        Alternative 9: 81.1% accurate, 5.6× speedup?

        \[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ \begin{array}{l} \mathbf{if}\;l\_m \leq 1.6 \cdot 10^{-82}:\\ \;\;\;\;1\\ \mathbf{elif}\;l\_m \leq 10^{+124}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5}{1 + 2 \cdot \frac{\left(ky \cdot ky\right) \cdot \left(l\_m \cdot l\_m\right)}{Om\_m \cdot Om\_m}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
        l_m = (fabs.f64 l)
        Om_m = (fabs.f64 Om)
        (FPCore (l_m Om_m kx ky)
         :precision binary64
         (if (<= l_m 1.6e-82)
           1.0
           (if (<= l_m 1e+124)
             (sqrt
              (+
               0.5
               (/ 0.5 (+ 1.0 (* 2.0 (/ (* (* ky ky) (* l_m l_m)) (* Om_m Om_m)))))))
             (sqrt 0.5))))
        l_m = fabs(l);
        Om_m = fabs(Om);
        double code(double l_m, double Om_m, double kx, double ky) {
        	double tmp;
        	if (l_m <= 1.6e-82) {
        		tmp = 1.0;
        	} else if (l_m <= 1e+124) {
        		tmp = sqrt((0.5 + (0.5 / (1.0 + (2.0 * (((ky * ky) * (l_m * l_m)) / (Om_m * Om_m)))))));
        	} else {
        		tmp = sqrt(0.5);
        	}
        	return tmp;
        }
        
        l_m = abs(l)
        Om_m = abs(om)
        real(8) function code(l_m, om_m, kx, ky)
            real(8), intent (in) :: l_m
            real(8), intent (in) :: om_m
            real(8), intent (in) :: kx
            real(8), intent (in) :: ky
            real(8) :: tmp
            if (l_m <= 1.6d-82) then
                tmp = 1.0d0
            else if (l_m <= 1d+124) then
                tmp = sqrt((0.5d0 + (0.5d0 / (1.0d0 + (2.0d0 * (((ky * ky) * (l_m * l_m)) / (om_m * om_m)))))))
            else
                tmp = sqrt(0.5d0)
            end if
            code = tmp
        end function
        
        l_m = Math.abs(l);
        Om_m = Math.abs(Om);
        public static double code(double l_m, double Om_m, double kx, double ky) {
        	double tmp;
        	if (l_m <= 1.6e-82) {
        		tmp = 1.0;
        	} else if (l_m <= 1e+124) {
        		tmp = Math.sqrt((0.5 + (0.5 / (1.0 + (2.0 * (((ky * ky) * (l_m * l_m)) / (Om_m * Om_m)))))));
        	} else {
        		tmp = Math.sqrt(0.5);
        	}
        	return tmp;
        }
        
        l_m = math.fabs(l)
        Om_m = math.fabs(Om)
        def code(l_m, Om_m, kx, ky):
        	tmp = 0
        	if l_m <= 1.6e-82:
        		tmp = 1.0
        	elif l_m <= 1e+124:
        		tmp = math.sqrt((0.5 + (0.5 / (1.0 + (2.0 * (((ky * ky) * (l_m * l_m)) / (Om_m * Om_m)))))))
        	else:
        		tmp = math.sqrt(0.5)
        	return tmp
        
        l_m = abs(l)
        Om_m = abs(Om)
        function code(l_m, Om_m, kx, ky)
        	tmp = 0.0
        	if (l_m <= 1.6e-82)
        		tmp = 1.0;
        	elseif (l_m <= 1e+124)
        		tmp = sqrt(Float64(0.5 + Float64(0.5 / Float64(1.0 + Float64(2.0 * Float64(Float64(Float64(ky * ky) * Float64(l_m * l_m)) / Float64(Om_m * Om_m)))))));
        	else
        		tmp = sqrt(0.5);
        	end
        	return tmp
        end
        
        l_m = abs(l);
        Om_m = abs(Om);
        function tmp_2 = code(l_m, Om_m, kx, ky)
        	tmp = 0.0;
        	if (l_m <= 1.6e-82)
        		tmp = 1.0;
        	elseif (l_m <= 1e+124)
        		tmp = sqrt((0.5 + (0.5 / (1.0 + (2.0 * (((ky * ky) * (l_m * l_m)) / (Om_m * Om_m)))))));
        	else
        		tmp = sqrt(0.5);
        	end
        	tmp_2 = tmp;
        end
        
        l_m = N[Abs[l], $MachinePrecision]
        Om_m = N[Abs[Om], $MachinePrecision]
        code[l$95$m_, Om$95$m_, kx_, ky_] := If[LessEqual[l$95$m, 1.6e-82], 1.0, If[LessEqual[l$95$m, 1e+124], N[Sqrt[N[(0.5 + N[(0.5 / N[(1.0 + N[(2.0 * N[(N[(N[(ky * ky), $MachinePrecision] * N[(l$95$m * l$95$m), $MachinePrecision]), $MachinePrecision] / N[(Om$95$m * Om$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]
        
        \begin{array}{l}
        l_m = \left|\ell\right|
        \\
        Om_m = \left|Om\right|
        
        \\
        \begin{array}{l}
        \mathbf{if}\;l\_m \leq 1.6 \cdot 10^{-82}:\\
        \;\;\;\;1\\
        
        \mathbf{elif}\;l\_m \leq 10^{+124}:\\
        \;\;\;\;\sqrt{0.5 + \frac{0.5}{1 + 2 \cdot \frac{\left(ky \cdot ky\right) \cdot \left(l\_m \cdot l\_m\right)}{Om\_m \cdot Om\_m}}}\\
        
        \mathbf{else}:\\
        \;\;\;\;\sqrt{0.5}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if l < 1.6000000000000001e-82

          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. sqrt-lowering-sqrt.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
            2. *-commutativeN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
            3. +-commutativeN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
            4. distribute-rgt1-inN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
            6. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
            7. associate-*l/N/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            8. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            9. metadata-evalN/A

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            10. metadata-evalN/A

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

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

            \[\leadsto \color{blue}{1} \]
          6. Step-by-step derivation
            1. Simplified68.4%

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

            if 1.6000000000000001e-82 < l < 9.99999999999999948e123

            1. Initial program 97.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. sqrt-lowering-sqrt.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
              2. *-commutativeN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
              3. +-commutativeN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
              4. distribute-rgt1-inN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
              5. +-lowering-+.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
              6. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
              7. associate-*l/N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              8. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              9. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              10. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            3. Simplified97.8%

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

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{1 + 4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}}\right)}\right)\right)\right) \]
            6. Step-by-step derivation
              1. sqrt-lowering-sqrt.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\left(1 + 4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right) \]
              2. +-lowering-+.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(4 \cdot \frac{{\ell}^{2} \cdot {\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
              3. associate-/l*N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(4 \cdot \left({\ell}^{2} \cdot \frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
              4. associate-*r*N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(\left(4 \cdot {\ell}^{2}\right) \cdot \frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
              5. *-lowering-*.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(4 \cdot {\ell}^{2}\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
              6. *-lowering-*.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \left({\ell}^{2}\right)\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
              7. unpow2N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \left(\ell \cdot \ell\right)\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
              8. *-lowering-*.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \left(\frac{{\sin ky}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right)\right) \]
              9. /-lowering-/.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\left({\sin ky}^{2}\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
              10. pow-lowering-pow.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\sin ky, 2\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
              11. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
              12. unpow2N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right), \left(Om \cdot Om\right)\right)\right)\right)\right)\right)\right)\right) \]
              13. *-lowering-*.f6485.6%

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(4, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right), \mathsf{*.f64}\left(Om, Om\right)\right)\right)\right)\right)\right)\right)\right) \]
            7. Simplified85.6%

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

              \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(1 + 2 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}\right)}\right)\right)\right) \]
            9. Step-by-step derivation
              1. +-lowering-+.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \left(2 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right) \]
              2. *-lowering-*.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \left(\frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}\right)\right)\right)\right)\right)\right) \]
              3. /-lowering-/.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\left({ky}^{2} \cdot {\ell}^{2}\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
              4. *-lowering-*.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({ky}^{2}\right), \left({\ell}^{2}\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
              5. unpow2N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(ky \cdot ky\right), \left({\ell}^{2}\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
              6. *-lowering-*.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \left({\ell}^{2}\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
              7. unpow2N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \left(\ell \cdot \ell\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
              8. *-lowering-*.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{*.f64}\left(\ell, \ell\right)\right), \left({Om}^{2}\right)\right)\right)\right)\right)\right)\right) \]
              9. unpow2N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{*.f64}\left(\ell, \ell\right)\right), \left(Om \cdot Om\right)\right)\right)\right)\right)\right)\right) \]
              10. *-lowering-*.f6471.7%

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{*.f64}\left(Om, Om\right)\right)\right)\right)\right)\right)\right) \]
            10. Simplified71.7%

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

            if 9.99999999999999948e123 < l

            1. Initial program 94.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. Step-by-step derivation
              1. sqrt-lowering-sqrt.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
              2. *-commutativeN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
              3. +-commutativeN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
              4. distribute-rgt1-inN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
              5. +-lowering-+.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
              6. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
              7. associate-*l/N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              8. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              9. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              10. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            3. Simplified94.9%

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

              \[\leadsto \color{blue}{\sqrt{\frac{1}{2}}} \]
            6. Step-by-step derivation
              1. sqrt-lowering-sqrt.f6493.8%

                \[\leadsto \mathsf{sqrt.f64}\left(\frac{1}{2}\right) \]
            7. Simplified93.8%

              \[\leadsto \color{blue}{\sqrt{0.5}} \]
          7. Recombined 3 regimes into one program.
          8. Add Preprocessing

          Alternative 10: 77.6% accurate, 6.8× speedup?

          \[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ \begin{array}{l} \mathbf{if}\;l\_m \leq 3.1 \cdot 10^{-41}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
          l_m = (fabs.f64 l)
          Om_m = (fabs.f64 Om)
          (FPCore (l_m Om_m kx ky)
           :precision binary64
           (if (<= l_m 3.1e-41) 1.0 (sqrt 0.5)))
          l_m = fabs(l);
          Om_m = fabs(Om);
          double code(double l_m, double Om_m, double kx, double ky) {
          	double tmp;
          	if (l_m <= 3.1e-41) {
          		tmp = 1.0;
          	} else {
          		tmp = sqrt(0.5);
          	}
          	return tmp;
          }
          
          l_m = abs(l)
          Om_m = abs(om)
          real(8) function code(l_m, om_m, kx, ky)
              real(8), intent (in) :: l_m
              real(8), intent (in) :: om_m
              real(8), intent (in) :: kx
              real(8), intent (in) :: ky
              real(8) :: tmp
              if (l_m <= 3.1d-41) then
                  tmp = 1.0d0
              else
                  tmp = sqrt(0.5d0)
              end if
              code = tmp
          end function
          
          l_m = Math.abs(l);
          Om_m = Math.abs(Om);
          public static double code(double l_m, double Om_m, double kx, double ky) {
          	double tmp;
          	if (l_m <= 3.1e-41) {
          		tmp = 1.0;
          	} else {
          		tmp = Math.sqrt(0.5);
          	}
          	return tmp;
          }
          
          l_m = math.fabs(l)
          Om_m = math.fabs(Om)
          def code(l_m, Om_m, kx, ky):
          	tmp = 0
          	if l_m <= 3.1e-41:
          		tmp = 1.0
          	else:
          		tmp = math.sqrt(0.5)
          	return tmp
          
          l_m = abs(l)
          Om_m = abs(Om)
          function code(l_m, Om_m, kx, ky)
          	tmp = 0.0
          	if (l_m <= 3.1e-41)
          		tmp = 1.0;
          	else
          		tmp = sqrt(0.5);
          	end
          	return tmp
          end
          
          l_m = abs(l);
          Om_m = abs(Om);
          function tmp_2 = code(l_m, Om_m, kx, ky)
          	tmp = 0.0;
          	if (l_m <= 3.1e-41)
          		tmp = 1.0;
          	else
          		tmp = sqrt(0.5);
          	end
          	tmp_2 = tmp;
          end
          
          l_m = N[Abs[l], $MachinePrecision]
          Om_m = N[Abs[Om], $MachinePrecision]
          code[l$95$m_, Om$95$m_, kx_, ky_] := If[LessEqual[l$95$m, 3.1e-41], 1.0, N[Sqrt[0.5], $MachinePrecision]]
          
          \begin{array}{l}
          l_m = \left|\ell\right|
          \\
          Om_m = \left|Om\right|
          
          \\
          \begin{array}{l}
          \mathbf{if}\;l\_m \leq 3.1 \cdot 10^{-41}:\\
          \;\;\;\;1\\
          
          \mathbf{else}:\\
          \;\;\;\;\sqrt{0.5}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if l < 3.10000000000000001e-41

            1. Initial program 97.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. sqrt-lowering-sqrt.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
              2. *-commutativeN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
              3. +-commutativeN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
              4. distribute-rgt1-inN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
              5. +-lowering-+.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
              6. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
              7. associate-*l/N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              8. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              9. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              10. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
            3. Simplified97.8%

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

              \[\leadsto \color{blue}{1} \]
            6. Step-by-step derivation
              1. Simplified69.1%

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

              if 3.10000000000000001e-41 < l

              1. Initial program 96.1%

                \[\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. sqrt-lowering-sqrt.f64N/A

                  \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
                2. *-commutativeN/A

                  \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
                3. +-commutativeN/A

                  \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
                4. distribute-rgt1-inN/A

                  \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
                5. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
                6. metadata-evalN/A

                  \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
                7. associate-*l/N/A

                  \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
                8. metadata-evalN/A

                  \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
                9. metadata-evalN/A

                  \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
                10. metadata-evalN/A

                  \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              3. Simplified96.1%

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

                \[\leadsto \color{blue}{\sqrt{\frac{1}{2}}} \]
              6. Step-by-step derivation
                1. sqrt-lowering-sqrt.f6479.2%

                  \[\leadsto \mathsf{sqrt.f64}\left(\frac{1}{2}\right) \]
              7. Simplified79.2%

                \[\leadsto \color{blue}{\sqrt{0.5}} \]
            7. Recombined 2 regimes into one program.
            8. Add Preprocessing

            Alternative 11: 62.7% accurate, 722.0× speedup?

            \[\begin{array}{l} l_m = \left|\ell\right| \\ Om_m = \left|Om\right| \\ 1 \end{array} \]
            l_m = (fabs.f64 l)
            Om_m = (fabs.f64 Om)
            (FPCore (l_m Om_m kx ky) :precision binary64 1.0)
            l_m = fabs(l);
            Om_m = fabs(Om);
            double code(double l_m, double Om_m, double kx, double ky) {
            	return 1.0;
            }
            
            l_m = abs(l)
            Om_m = abs(om)
            real(8) function code(l_m, om_m, kx, ky)
                real(8), intent (in) :: l_m
                real(8), intent (in) :: om_m
                real(8), intent (in) :: kx
                real(8), intent (in) :: ky
                code = 1.0d0
            end function
            
            l_m = Math.abs(l);
            Om_m = Math.abs(Om);
            public static double code(double l_m, double Om_m, double kx, double ky) {
            	return 1.0;
            }
            
            l_m = math.fabs(l)
            Om_m = math.fabs(Om)
            def code(l_m, Om_m, kx, ky):
            	return 1.0
            
            l_m = abs(l)
            Om_m = abs(Om)
            function code(l_m, Om_m, kx, ky)
            	return 1.0
            end
            
            l_m = abs(l);
            Om_m = abs(Om);
            function tmp = code(l_m, Om_m, kx, ky)
            	tmp = 1.0;
            end
            
            l_m = N[Abs[l], $MachinePrecision]
            Om_m = N[Abs[Om], $MachinePrecision]
            code[l$95$m_, Om$95$m_, kx_, ky_] := 1.0
            
            \begin{array}{l}
            l_m = \left|\ell\right|
            \\
            Om_m = \left|Om\right|
            
            \\
            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. Step-by-step derivation
              1. sqrt-lowering-sqrt.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\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)\right)\right) \]
              2. *-commutativeN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right) \cdot \frac{1}{2}\right)\right) \]
              3. +-commutativeN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}} + 1\right) \cdot \frac{1}{2}\right)\right) \]
              4. distribute-rgt1-inN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\left(\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}\right)\right) \]
              5. +-lowering-+.f64N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{2}\right), \left(\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}\right)\right)\right) \]
              6. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\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}\right)\right)\right) \]
              7. associate-*l/N/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              8. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              9. metadata-evalN/A

                \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{2}}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)\right)\right) \]
              10. metadata-evalN/A

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

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

              \[\leadsto \color{blue}{1} \]
            6. Step-by-step derivation
              1. Simplified60.3%

                \[\leadsto \color{blue}{1} \]
              2. Add Preprocessing

              Reproduce

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