Toniolo and Linder, Equation (3a)

Percentage Accurate: 98.5% → 100.0%
Time: 18.3s
Alternatives: 9
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 9 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 98.4%

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

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

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

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

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

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

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

      \[\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-sqrt98.4%

      \[\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-down98.4%

      \[\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: 93.6% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \sqrt{0.5 + 0.5 \cdot {\left(\sqrt{\mathsf{hypot}\left(1, \frac{2 \cdot \left(\sin ky \cdot \ell\right)}{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 ky) 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(ky) * 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(ky) * 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(ky) * l)) / Om))), -2.0))))
function code(l, Om, kx, ky)
	return sqrt(Float64(0.5 + Float64(0.5 * (sqrt(hypot(1.0, Float64(Float64(2.0 * Float64(sin(ky) * 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(ky) * 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[(N[(2.0 * N[(N[Sin[ky], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] / Om), $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, \frac{2 \cdot \left(\sin ky \cdot \ell\right)}{Om}\right)}\right)}^{-2}}
\end{array}
Derivation
  1. Initial program 98.4%

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

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

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

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

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

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

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

      \[\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-sqrt98.4%

      \[\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-down98.4%

      \[\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 kx around 0 93.9%

    \[\leadsto \sqrt{0.5 + {\left(\sqrt{\mathsf{hypot}\left(1, \color{blue}{2 \cdot \frac{\ell \cdot \sin ky}{Om}}\right)}\right)}^{-2} \cdot 0.5} \]
  9. Step-by-step derivation
    1. associate-*r/93.9%

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

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

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

Alternative 3: 100.0% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

      \[\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-sqrt98.4%

      \[\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-down98.4%

      \[\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. Step-by-step derivation
    1. expm1-log1p-u100.0%

      \[\leadsto \sqrt{0.5 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\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}\right)\right)} \cdot 0.5} \]
    2. expm1-udef100.0%

      \[\leadsto \sqrt{0.5 + \color{blue}{\left(e^{\mathsf{log1p}\left({\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}\right)} - 1\right)} \cdot 0.5} \]
    3. sqrt-pow2100.0%

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

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

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

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

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

      \[\leadsto \sqrt{0.5 + \color{blue}{\frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
    4. 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}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
    5. 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}{\frac{Om}{2}}}\right)} \cdot 0.5} \]
  11. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 90.4% accurate, 2.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if kx < 2.5e-141

    1. Initial program 97.4%

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

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

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

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

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

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

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

        \[\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-sqrt97.4%

        \[\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-down97.4%

        \[\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 kx around 0 96.1%

      \[\leadsto \sqrt{0.5 + {\left(\sqrt{\mathsf{hypot}\left(1, \color{blue}{2 \cdot \frac{\ell \cdot \sin ky}{Om}}\right)}\right)}^{-2} \cdot 0.5} \]
    9. Step-by-step derivation
      1. associate-*r/96.1%

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

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

      \[\leadsto \sqrt{0.5 + {\left(\sqrt{\mathsf{hypot}\left(1, \frac{2 \cdot \color{blue}{\left(\ell \cdot ky\right)}}{Om}\right)}\right)}^{-2} \cdot 0.5} \]
    12. Step-by-step derivation
      1. *-un-lft-identity88.0%

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

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

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

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

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

      \[\leadsto \sqrt{0.5 + \color{blue}{\left(1 \cdot {\left(\mathsf{hypot}\left(1, \frac{2}{\frac{Om}{ky \cdot \ell}}\right)\right)}^{-1}\right)} \cdot 0.5} \]
    14. Step-by-step derivation
      1. *-lft-identity88.0%

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

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

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

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

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

    if 2.5e-141 < kx

    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. Step-by-step derivation
      1. expm1-log1p-u100.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\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}\right)\right)} \cdot 0.5} \]
      2. expm1-udef100.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{\left(e^{\mathsf{log1p}\left({\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}\right)} - 1\right)} \cdot 0.5} \]
      3. sqrt-pow2100.0%

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + \color{blue}{\frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
      4. 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}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      5. 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}{\frac{Om}{2}}}\right)} \cdot 0.5} \]
    11. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 93.6% accurate, 2.3× speedup?

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

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

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

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

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

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

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

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

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

      \[\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-sqrt98.4%

      \[\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-down98.4%

      \[\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. Step-by-step derivation
    1. expm1-log1p-u100.0%

      \[\leadsto \sqrt{0.5 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\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}\right)\right)} \cdot 0.5} \]
    2. expm1-udef100.0%

      \[\leadsto \sqrt{0.5 + \color{blue}{\left(e^{\mathsf{log1p}\left({\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}\right)} - 1\right)} \cdot 0.5} \]
    3. sqrt-pow2100.0%

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

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

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

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

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

      \[\leadsto \sqrt{0.5 + \color{blue}{\frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
    4. 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}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
    5. 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}{\frac{Om}{2}}}\right)} \cdot 0.5} \]
  11. Simplified100.0%

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

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

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

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

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

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

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

Alternative 6: 73.2% accurate, 3.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.74999999999999998e-50

    1. Initial program 97.7%

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

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

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

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

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

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

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

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

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

        \[\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. Step-by-step derivation
      1. expm1-log1p-u100.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\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}\right)\right)} \cdot 0.5} \]
      2. expm1-udef100.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{\left(e^{\mathsf{log1p}\left({\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}\right)} - 1\right)} \cdot 0.5} \]
      3. sqrt-pow2100.0%

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + \color{blue}{\frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
      4. 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}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      5. 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}{\frac{Om}{2}}}\right)} \cdot 0.5} \]
    11. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.74999999999999998e-50 < 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. 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 kx around 0 92.8%

      \[\leadsto \sqrt{0.5 + {\left(\sqrt{\mathsf{hypot}\left(1, \color{blue}{2 \cdot \frac{\ell \cdot \sin ky}{Om}}\right)}\right)}^{-2} \cdot 0.5} \]
    9. Step-by-step derivation
      1. associate-*r/92.8%

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

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

      \[\leadsto \sqrt{0.5 + {\left(\sqrt{\mathsf{hypot}\left(1, \frac{2 \cdot \color{blue}{\left(\ell \cdot ky\right)}}{Om}\right)}\right)}^{-2} \cdot 0.5} \]
    12. Step-by-step derivation
      1. *-un-lft-identity85.6%

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

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

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

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

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

      \[\leadsto \sqrt{0.5 + \color{blue}{\left(1 \cdot {\left(\mathsf{hypot}\left(1, \frac{2}{\frac{Om}{ky \cdot \ell}}\right)\right)}^{-1}\right)} \cdot 0.5} \]
    14. Step-by-step derivation
      1. *-lft-identity85.6%

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

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

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

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

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

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

Alternative 7: 68.2% accurate, 6.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;Om \leq 10^{-59}:\\
\;\;\;\;\sqrt{0.5}\\

\mathbf{elif}\;Om \leq 2 \cdot 10^{-50}:\\
\;\;\;\;1\\

\mathbf{elif}\;Om \leq 5000000000000:\\
\;\;\;\;\sqrt{0.5}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if Om < 1e-59 or 2.00000000000000002e-50 < Om < 5e12

    1. Initial program 98.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-in98.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-eval98.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-eval98.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*98.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-eval98.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. Simplified98.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 Om around 0 51.6%

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

        \[\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-*r*51.6%

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

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

        \[\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-def53.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. associate-*l/53.3%

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

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

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

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

    if 1e-59 < Om < 2.00000000000000002e-50 or 5e12 < 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. 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. Step-by-step derivation
      1. expm1-log1p-u100.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\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}\right)\right)} \cdot 0.5} \]
      2. expm1-udef100.0%

        \[\leadsto \sqrt{0.5 + \color{blue}{\left(e^{\mathsf{log1p}\left({\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}\right)} - 1\right)} \cdot 0.5} \]
      3. sqrt-pow2100.0%

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + \color{blue}{\frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}} \cdot 0.5} \]
      4. 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}{\frac{\ell \cdot 2}{Om}}\right)} \cdot 0.5} \]
      5. 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}{\frac{Om}{2}}}\right)} \cdot 0.5} \]
    11. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;Om \leq 10^{-59}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{elif}\;Om \leq 2 \cdot 10^{-50}:\\ \;\;\;\;1\\ \mathbf{elif}\;Om \leq 5000000000000:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 8: 61.3% accurate, 7.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;Om \leq 8 \cdot 10^{+76}:\\
\;\;\;\;\sqrt{0.5}\\

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


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

    1. Initial program 98.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. distribute-rgt-in98.1%

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

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

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

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

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

      \[\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 Om around 0 51.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. *-commutative51.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-*r*51.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. unpow251.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. unpow251.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-def53.0%

        \[\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. associate-*l/53.0%

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

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

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

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

    if 8.0000000000000004e76 < 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. Taylor expanded in kx around 0 82.9%

      \[\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/82.9%

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

        \[\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*82.9%

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

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

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

      \[\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 l around 0 78.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{\color{blue}{ky \cdot ky}}} \]
    12. Simplified60.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;Om \leq 8 \cdot 10^{+76}:\\ \;\;\;\;\sqrt{0.5}\\ \mathbf{else}:\\ \;\;\;\;1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}\\ \end{array} \]

Alternative 9: 33.1% accurate, 48.1× speedup?

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

\\
1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}
\end{array}
Derivation
  1. Initial program 98.4%

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

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

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

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

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

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

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

    \[\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/79.7%

      \[\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. *-commutative79.7%

      \[\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*79.7%

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

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

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

    \[\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 l around 0 50.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{\color{blue}{ky \cdot ky}}} \]
  12. Simplified36.8%

    \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}} \]
  13. Final simplification36.8%

    \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}} \]

Reproduce

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