Toniolo and Linder, Equation (3a)

Percentage Accurate: 98.5% → 100.0%
Time: 17.8s
Alternatives: 8
Speedup: 1.4×

Specification

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

\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 98.5% accurate, 1.0× speedup?

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

\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

    \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
  2. Step-by-step derivation
    1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 100.0% accurate, 1.4× speedup?

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

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

    \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
  2. Step-by-step derivation
    1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 93.6% accurate, 1.4× speedup?

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

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

    \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
  2. Step-by-step derivation
    1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.6% accurate, 2.3× speedup?

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

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

    \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
  2. Step-by-step derivation
    1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{0.5 + \log \left(e^{\frac{1}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \color{blue}{\sin kx}\right)}}\right) \cdot 0.5} \]
  7. Step-by-step derivation
    1. *-un-lft-identity94.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 81.6% accurate, 5.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{kx \cdot kx}}}}\\ \mathbf{if}\;\ell \leq -9 \cdot 10^{+153}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{elif}\;\ell \leq -1.15 \cdot 10^{-35}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 1.15 \cdot 10^{-67}:\\ \;\;\;\;1\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+85}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (let* ((t_0
         (sqrt
          (+
           0.5
           (*
            0.5
            (/ 1.0 (+ 1.0 (* 2.0 (/ (* l l) (/ (* Om Om) (* kx kx)))))))))))
   (if (<= l -9e+153)
     (sqrt 0.5)
     (if (<= l -1.15e-35)
       t_0
       (if (<= l 1.15e-67)
         1.0
         (if (<= l 1.65e+40) t_0 (if (<= l 1.1e+85) 1.0 (sqrt 0.5))))))))
double code(double l, double Om, double kx, double ky) {
	double t_0 = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))));
	double tmp;
	if (l <= -9e+153) {
		tmp = sqrt(0.5);
	} else if (l <= -1.15e-35) {
		tmp = t_0;
	} else if (l <= 1.15e-67) {
		tmp = 1.0;
	} else if (l <= 1.65e+40) {
		tmp = t_0;
	} else if (l <= 1.1e+85) {
		tmp = 1.0;
	} else {
		tmp = sqrt(0.5);
	}
	return tmp;
}
real(8) function code(l, om, kx, ky)
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((l * l) / ((om * om) / (kx * kx)))))))))
    if (l <= (-9d+153)) then
        tmp = sqrt(0.5d0)
    else if (l <= (-1.15d-35)) then
        tmp = t_0
    else if (l <= 1.15d-67) then
        tmp = 1.0d0
    else if (l <= 1.65d+40) then
        tmp = t_0
    else if (l <= 1.1d+85) then
        tmp = 1.0d0
    else
        tmp = sqrt(0.5d0)
    end if
    code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
	double t_0 = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))));
	double tmp;
	if (l <= -9e+153) {
		tmp = Math.sqrt(0.5);
	} else if (l <= -1.15e-35) {
		tmp = t_0;
	} else if (l <= 1.15e-67) {
		tmp = 1.0;
	} else if (l <= 1.65e+40) {
		tmp = t_0;
	} else if (l <= 1.1e+85) {
		tmp = 1.0;
	} else {
		tmp = Math.sqrt(0.5);
	}
	return tmp;
}
def code(l, Om, kx, ky):
	t_0 = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))))
	tmp = 0
	if l <= -9e+153:
		tmp = math.sqrt(0.5)
	elif l <= -1.15e-35:
		tmp = t_0
	elif l <= 1.15e-67:
		tmp = 1.0
	elif l <= 1.65e+40:
		tmp = t_0
	elif l <= 1.1e+85:
		tmp = 1.0
	else:
		tmp = math.sqrt(0.5)
	return tmp
function code(l, Om, kx, ky)
	t_0 = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(l * l) / Float64(Float64(Om * Om) / Float64(kx * kx)))))))))
	tmp = 0.0
	if (l <= -9e+153)
		tmp = sqrt(0.5);
	elseif (l <= -1.15e-35)
		tmp = t_0;
	elseif (l <= 1.15e-67)
		tmp = 1.0;
	elseif (l <= 1.65e+40)
		tmp = t_0;
	elseif (l <= 1.1e+85)
		tmp = 1.0;
	else
		tmp = sqrt(0.5);
	end
	return tmp
end
function tmp_2 = code(l, Om, kx, ky)
	t_0 = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))));
	tmp = 0.0;
	if (l <= -9e+153)
		tmp = sqrt(0.5);
	elseif (l <= -1.15e-35)
		tmp = t_0;
	elseif (l <= 1.15e-67)
		tmp = 1.0;
	elseif (l <= 1.65e+40)
		tmp = t_0;
	elseif (l <= 1.1e+85)
		tmp = 1.0;
	else
		tmp = sqrt(0.5);
	end
	tmp_2 = tmp;
end
code[l_, Om_, kx_, ky_] := Block[{t$95$0 = N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -9e+153], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, -1.15e-35], t$95$0, If[LessEqual[l, 1.15e-67], 1.0, If[LessEqual[l, 1.65e+40], t$95$0, If[LessEqual[l, 1.1e+85], 1.0, N[Sqrt[0.5], $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{kx \cdot kx}}}}\\
\mathbf{if}\;\ell \leq -9 \cdot 10^{+153}:\\
\;\;\;\;\sqrt{0.5}\\

\mathbf{elif}\;\ell \leq -1.15 \cdot 10^{-35}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq 1.15 \cdot 10^{-67}:\\
\;\;\;\;1\\

\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+40}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+85}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -9.0000000000000002e153 or 1.1000000000000001e85 < l

    1. Initial program 100.0%

      \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.0000000000000002e153 < l < -1.1499999999999999e-35 or 1.15e-67 < l < 1.6499999999999999e40

    1. Initial program 100.0%

      \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + 4 \cdot \color{blue}{\frac{{\sin kx}^{2}}{\frac{{Om}^{2}}{{\ell}^{2}}}}}} \cdot 0.5} \]
      2. associate-*r/91.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + \color{blue}{\frac{4 \cdot {\sin kx}^{2}}{\frac{{Om}^{2}}{{\ell}^{2}}}}}} \cdot 0.5} \]
      3. unpow291.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + \frac{4 \cdot {\sin kx}^{2}}{\frac{\color{blue}{Om \cdot Om}}{{\ell}^{2}}}}} \cdot 0.5} \]
      4. unpow291.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + \frac{4 \cdot {\sin kx}^{2}}{\frac{Om \cdot Om}{\color{blue}{\ell \cdot \ell}}}}} \cdot 0.5} \]
      5. times-frac91.7%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + \frac{4 \cdot {\sin kx}^{2}}{\color{blue}{\frac{Om}{\ell} \cdot \frac{Om}{\ell}}}}} \cdot 0.5} \]
    6. Simplified91.7%

      \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + \color{blue}{\frac{4 \cdot {\sin kx}^{2}}{\frac{Om}{\ell} \cdot \frac{Om}{\ell}}}}} \cdot 0.5} \]
    7. Taylor expanded in kx around 0 78.3%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{1 + 2 \cdot \color{blue}{\frac{{\ell}^{2}}{\frac{{Om}^{2}}{{kx}^{2}}}}} \cdot 0.5} \]
      2. unpow281.5%

        \[\leadsto \sqrt{0.5 + \frac{1}{1 + 2 \cdot \frac{\color{blue}{\ell \cdot \ell}}{\frac{{Om}^{2}}{{kx}^{2}}}} \cdot 0.5} \]
      3. unpow281.5%

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

        \[\leadsto \sqrt{0.5 + \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{\color{blue}{kx \cdot kx}}}} \cdot 0.5} \]
    9. Simplified81.5%

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

    if -1.1499999999999999e-35 < l < 1.15e-67 or 1.6499999999999999e40 < l < 1.1000000000000001e85

    1. Initial program 100.0%

      \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9 \cdot 10^{+153}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{elif}\;\ell \leq -1.15 \cdot 10^{-35}:\\ \;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{kx \cdot kx}}}}\\ \mathbf{elif}\;\ell \leq 1.15 \cdot 10^{-67}:\\ \;\;\;\;1\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+40}:\\ \;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{kx \cdot kx}}}}\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+85}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \]

Alternative 6: 82.6% accurate, 5.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -7.8 \cdot 10^{+149}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{elif}\;\ell \leq -9 \cdot 10^{-37}:\\ \;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{kx \cdot kx}}}}\\ \mathbf{elif}\;\ell \leq 4.7 \cdot 10^{-92}:\\ \;\;\;\;1\\ \mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+128}:\\ \;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \end{array} \]
(FPCore (l Om kx ky)
 :precision binary64
 (if (<= l -7.8e+149)
   (sqrt 0.5)
   (if (<= l -9e-37)
     (sqrt
      (+
       0.5
       (* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (/ (* l l) (/ (* Om Om) (* kx kx)))))))))
     (if (<= l 4.7e-92)
       1.0
       (if (<= l 1.8e+128)
         (sqrt
          (+
           0.5
           (*
            0.5
            (/ 1.0 (+ 1.0 (* 2.0 (/ (* l l) (/ (* Om Om) (* ky ky)))))))))
         (sqrt 0.5))))))
double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (l <= -7.8e+149) {
		tmp = sqrt(0.5);
	} else if (l <= -9e-37) {
		tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))));
	} else if (l <= 4.7e-92) {
		tmp = 1.0;
	} else if (l <= 1.8e+128) {
		tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))));
	} else {
		tmp = sqrt(0.5);
	}
	return tmp;
}
real(8) function code(l, om, kx, ky)
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8) :: tmp
    if (l <= (-7.8d+149)) then
        tmp = sqrt(0.5d0)
    else if (l <= (-9d-37)) then
        tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((l * l) / ((om * om) / (kx * kx)))))))))
    else if (l <= 4.7d-92) then
        tmp = 1.0d0
    else if (l <= 1.8d+128) then
        tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((l * l) / ((om * om) / (ky * ky)))))))))
    else
        tmp = sqrt(0.5d0)
    end if
    code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
	double tmp;
	if (l <= -7.8e+149) {
		tmp = Math.sqrt(0.5);
	} else if (l <= -9e-37) {
		tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))));
	} else if (l <= 4.7e-92) {
		tmp = 1.0;
	} else if (l <= 1.8e+128) {
		tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))));
	} else {
		tmp = Math.sqrt(0.5);
	}
	return tmp;
}
def code(l, Om, kx, ky):
	tmp = 0
	if l <= -7.8e+149:
		tmp = math.sqrt(0.5)
	elif l <= -9e-37:
		tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))))
	elif l <= 4.7e-92:
		tmp = 1.0
	elif l <= 1.8e+128:
		tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))))
	else:
		tmp = math.sqrt(0.5)
	return tmp
function code(l, Om, kx, ky)
	tmp = 0.0
	if (l <= -7.8e+149)
		tmp = sqrt(0.5);
	elseif (l <= -9e-37)
		tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(l * l) / Float64(Float64(Om * Om) / Float64(kx * kx)))))))));
	elseif (l <= 4.7e-92)
		tmp = 1.0;
	elseif (l <= 1.8e+128)
		tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(l * l) / Float64(Float64(Om * Om) / Float64(ky * ky)))))))));
	else
		tmp = sqrt(0.5);
	end
	return tmp
end
function tmp_2 = code(l, Om, kx, ky)
	tmp = 0.0;
	if (l <= -7.8e+149)
		tmp = sqrt(0.5);
	elseif (l <= -9e-37)
		tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))));
	elseif (l <= 4.7e-92)
		tmp = 1.0;
	elseif (l <= 1.8e+128)
		tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))));
	else
		tmp = sqrt(0.5);
	end
	tmp_2 = tmp;
end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, -7.8e+149], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, -9e-37], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 4.7e-92], 1.0, If[LessEqual[l, 1.8e+128], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -9 \cdot 10^{-37}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{kx \cdot kx}}}}\\

\mathbf{elif}\;\ell \leq 4.7 \cdot 10^{-92}:\\
\;\;\;\;1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -7.7999999999999998e149 or 1.80000000000000014e128 < l

    1. Initial program 100.0%

      \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.7999999999999998e149 < l < -9.00000000000000081e-37

    1. Initial program 99.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. distribute-rgt-in99.9%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + 4 \cdot \color{blue}{\frac{{\sin kx}^{2}}{\frac{{Om}^{2}}{{\ell}^{2}}}}}} \cdot 0.5} \]
      2. associate-*r/88.3%

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

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

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + \frac{4 \cdot {\sin kx}^{2}}{\frac{Om \cdot Om}{\color{blue}{\ell \cdot \ell}}}}} \cdot 0.5} \]
      5. times-frac88.3%

        \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + \frac{4 \cdot {\sin kx}^{2}}{\color{blue}{\frac{Om}{\ell} \cdot \frac{Om}{\ell}}}}} \cdot 0.5} \]
    6. Simplified88.3%

      \[\leadsto \sqrt{0.5 + \frac{1}{\sqrt{1 + \color{blue}{\frac{4 \cdot {\sin kx}^{2}}{\frac{Om}{\ell} \cdot \frac{Om}{\ell}}}}} \cdot 0.5} \]
    7. Taylor expanded in kx around 0 77.9%

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

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

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

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

        \[\leadsto \sqrt{0.5 + \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{\color{blue}{kx \cdot kx}}}} \cdot 0.5} \]
    9. Simplified81.1%

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

    if -9.00000000000000081e-37 < l < 4.69999999999999993e-92

    1. Initial program 100.0%

      \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{0.5 + \color{blue}{1} \cdot 0.5} \]

    if 4.69999999999999993e-92 < l < 1.80000000000000014e128

    1. Initial program 100.0%

      \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{\color{blue}{ky \cdot ky}}}} \cdot 0.5} \]
    9. Simplified78.7%

      \[\leadsto \sqrt{0.5 + \frac{1}{\color{blue}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}}} \cdot 0.5} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification84.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.8 \cdot 10^{+149}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{elif}\;\ell \leq -9 \cdot 10^{-37}:\\ \;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{kx \cdot kx}}}}\\ \mathbf{elif}\;\ell \leq 4.7 \cdot 10^{-92}:\\ \;\;\;\;1\\ \mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+128}:\\ \;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5}\\ \end{array} \]

Alternative 7: 78.2% accurate, 6.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;Om \leq -1.02 \cdot 10^{+80}:\\
\;\;\;\;1\\

\mathbf{elif}\;Om \leq -1.55 \cdot 10^{+65}:\\
\;\;\;\;\sqrt{0.5}\\

\mathbf{elif}\;Om \leq -2.5 \cdot 10^{-86}:\\
\;\;\;\;1\\

\mathbf{elif}\;Om \leq 10^{-37}:\\
\;\;\;\;\sqrt{0.5}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if Om < -1.02e80 or -1.54999999999999995e65 < Om < -2.4999999999999999e-86 or 1.00000000000000007e-37 < Om

    1. Initial program 100.0%

      \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{0.5 + \color{blue}{1} \cdot 0.5} \]

    if -1.02e80 < Om < -1.54999999999999995e65 or -2.4999999999999999e-86 < Om < 1.00000000000000007e-37

    1. Initial program 100.0%

      \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;Om \leq -1.02 \cdot 10^{+80}:\\ \;\;\;\;1\\ \mathbf{elif}\;Om \leq -1.55 \cdot 10^{+65}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{elif}\;Om \leq -2.5 \cdot 10^{-86}:\\ \;\;\;\;1\\ \mathbf{elif}\;Om \leq 10^{-37}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 8: 56.0% accurate, 7.1× speedup?

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

\\
\sqrt{0.5}
\end{array}
Derivation
  1. Initial program 100.0%

    \[\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)} \]
  2. Step-by-step derivation
    1. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{0.5}} \]
  8. Final simplification50.5%

    \[\leadsto \sqrt{0.5} \]

Reproduce

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