Toniolo and Linder, Equation (3a)

Percentage Accurate: 98.1% → 100.0%
Time: 24.3s
Alternatives: 10
Speedup: 1.0×

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 10 alternatives:

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

Initial Program: 98.1% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

      \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\color{blue}{\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)}}}}} \]
    2. pow2100.0%

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

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

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

Alternative 2: 94.4% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 94.4% accurate, 2.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 63.1% accurate, 7.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;Om \leq 8500000000000:\\
\;\;\;\;\sqrt{0.5}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin kx \cdot \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \frac{4}{Om \cdot Om}}}} \]
      8. unswap-sqr79.0%

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

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

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

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

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

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

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

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

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

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

    if 8.5e12 < Om

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \sin ky\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \frac{4}{Om \cdot Om}}}} \]
      8. unswap-sqr89.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}} \]
    7. Step-by-step derivation
      1. unpow255.3%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \left(\frac{ky \cdot ky}{Om} \cdot \frac{\ell \cdot \ell}{Om}\right)} \]
    9. Step-by-step derivation
      1. *-commutative55.3%

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

        \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\frac{\ell}{\frac{Om}{\ell}}} \cdot \frac{ky \cdot ky}{Om}\right) \]
      3. associate-/l*66.3%

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

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{\ell \cdot ky}{\frac{Om}{\ell} \cdot \frac{Om}{ky}}} \]
    10. Applied egg-rr71.7%

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

        \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot ky}{\color{blue}{\frac{\frac{Om}{\ell} \cdot Om}{ky}}} \]
    12. Applied egg-rr75.0%

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

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

Alternative 5: 66.9% accurate, 7.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if Om < 2e-19

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin kx \cdot \sin kx\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \frac{4}{Om \cdot Om}}}} \]
      8. unswap-sqr78.6%

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin kx \cdot \ell\right) \cdot \left(\sin kx \cdot \ell\right)\right) \cdot \color{blue}{\frac{\frac{4}{Om}}{Om}}}}} \]
      10. metadata-eval78.6%

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin kx \cdot \ell\right) \cdot \left(\sin kx \cdot \ell\right)\right) \cdot \color{blue}{\left(\frac{2}{Om} \cdot \frac{2}{Om}\right)}}}} \]
      13. swap-sqr92.8%

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

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

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

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

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

    if 2e-19 < Om

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \sin ky\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \frac{4}{Om \cdot Om}}}} \]
      8. unswap-sqr90.4%

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\frac{\frac{4}{Om}}{Om}}}}} \]
      10. metadata-eval90.4%

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\left(\frac{2}{Om} \cdot \frac{2}{Om}\right)}}}} \]
      13. swap-sqr93.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 45.9% accurate, 42.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 10^{+61}:\\
\;\;\;\;1 + -0.5 \cdot \frac{ky}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \sin ky\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \frac{4}{Om \cdot Om}}}} \]
      8. unswap-sqr82.4%

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\frac{\frac{4}{Om}}{Om}}}}} \]
      10. metadata-eval82.4%

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\left(\frac{2}{Om} \cdot \frac{2}{Om}\right)}}}} \]
      13. swap-sqr92.5%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}} \]
    7. Step-by-step derivation
      1. unpow244.5%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \left(\frac{ky \cdot ky}{Om} \cdot \frac{\ell \cdot \ell}{Om}\right)} \]
    9. Step-by-step derivation
      1. *-commutative46.2%

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

        \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\frac{1}{\frac{Om}{\ell \cdot \ell}}} \cdot \frac{ky \cdot ky}{Om}\right) \]
      3. associate-/l*49.1%

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

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{1 \cdot ky}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}}} \]
      5. *-un-lft-identity55.9%

        \[\leadsto 1 + -0.5 \cdot \frac{\color{blue}{ky}}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}} \]
    10. Applied egg-rr55.9%

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

    if 9.99999999999999949e60 < l

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\left(\frac{2}{Om} \cdot \frac{2}{Om}\right)}}}} \]
      13. swap-sqr91.8%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}} \]
    7. Step-by-step derivation
      1. unpow29.1%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \left(\frac{ky \cdot ky}{Om} \cdot \frac{\ell \cdot \ell}{Om}\right)} \]
    9. Step-by-step derivation
      1. *-commutative10.4%

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

        \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\frac{\ell}{\frac{Om}{\ell}}} \cdot \frac{ky \cdot ky}{Om}\right) \]
      3. associate-/l*21.5%

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

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{\ell \cdot ky}{\frac{Om}{\ell} \cdot \frac{Om}{ky}}} \]
    10. Applied egg-rr22.3%

      \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{\ell \cdot ky}{\frac{Om}{\ell} \cdot \frac{Om}{ky}}} \]
    11. Step-by-step derivation
      1. times-frac21.5%

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

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

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

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

Alternative 7: 46.4% accurate, 42.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.12 \cdot 10^{+156}:\\
\;\;\;\;1 + -0.5 \cdot \frac{ky}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \sin ky\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \frac{4}{Om \cdot Om}}}} \]
      8. unswap-sqr83.8%

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\frac{\frac{4}{Om}}{Om}}}}} \]
      10. metadata-eval83.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}} \]
    7. Step-by-step derivation
      1. unpow241.9%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \left(\frac{ky \cdot ky}{Om} \cdot \frac{\ell \cdot \ell}{Om}\right)} \]
    9. Step-by-step derivation
      1. *-commutative43.8%

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

        \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\frac{1}{\frac{Om}{\ell \cdot \ell}}} \cdot \frac{ky \cdot ky}{Om}\right) \]
      3. associate-/l*46.4%

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

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{1 \cdot ky}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}}} \]
      5. *-un-lft-identity52.5%

        \[\leadsto 1 + -0.5 \cdot \frac{\color{blue}{ky}}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}} \]
    10. Applied egg-rr52.5%

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

    if 1.12000000000000007e156 < l

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \sin ky\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \frac{4}{Om \cdot Om}}}} \]
      8. unswap-sqr76.1%

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\frac{\frac{4}{Om}}{Om}}}}} \]
      10. metadata-eval76.1%

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\left(\frac{2}{Om} \cdot \frac{2}{Om}\right)}}}} \]
      13. swap-sqr87.6%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}} \]
    7. Step-by-step derivation
      1. unpow20.4%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \left(\frac{ky \cdot ky}{Om} \cdot \frac{\ell \cdot \ell}{Om}\right)} \]
    9. Step-by-step derivation
      1. clear-num0.4%

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

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

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{1 \cdot \ell}{\frac{Om}{ky \cdot ky} \cdot \frac{Om}{\ell}}} \]
      4. *-un-lft-identity19.7%

        \[\leadsto 1 + -0.5 \cdot \frac{\color{blue}{\ell}}{\frac{Om}{ky \cdot ky} \cdot \frac{Om}{\ell}} \]
    10. Applied egg-rr19.7%

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

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

Alternative 8: 47.0% accurate, 42.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 5 \cdot 10^{-66}:\\
\;\;\;\;1 + -0.5 \cdot \frac{ky}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \sin ky\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \frac{4}{Om \cdot Om}}}} \]
      8. unswap-sqr79.8%

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\frac{\frac{4}{Om}}{Om}}}}} \]
      10. metadata-eval79.8%

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\left(\frac{2}{Om} \cdot \frac{2}{Om}\right)}}}} \]
      13. swap-sqr91.7%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}} \]
    7. Step-by-step derivation
      1. unpow242.8%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \left(\frac{ky \cdot ky}{Om} \cdot \frac{\ell \cdot \ell}{Om}\right)} \]
    9. Step-by-step derivation
      1. *-commutative44.8%

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

        \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\frac{1}{\frac{Om}{\ell \cdot \ell}}} \cdot \frac{ky \cdot ky}{Om}\right) \]
      3. associate-/l*48.2%

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

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{1 \cdot ky}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}}} \]
      5. *-un-lft-identity56.2%

        \[\leadsto 1 + -0.5 \cdot \frac{\color{blue}{ky}}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}} \]
    10. Applied egg-rr56.2%

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

    if 4.99999999999999962e-66 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \sin ky\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \frac{4}{Om \cdot Om}}}} \]
      8. unswap-sqr90.1%

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

        \[\leadsto \sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \left(\left(\sin ky \cdot \ell\right) \cdot \left(\sin ky \cdot \ell\right)\right) \cdot \color{blue}{\frac{\frac{4}{Om}}{Om}}}}} \]
      10. metadata-eval90.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{ky}^{2} \cdot {\ell}^{2}}{{Om}^{2}}} \]
    7. Step-by-step derivation
      1. unpow226.3%

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

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

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

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

      \[\leadsto \color{blue}{1 + -0.5 \cdot \left(\frac{ky \cdot ky}{Om} \cdot \frac{\ell \cdot \ell}{Om}\right)} \]
    9. Step-by-step derivation
      1. *-commutative27.1%

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

        \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\frac{\ell}{\frac{Om}{\ell}}} \cdot \frac{ky \cdot ky}{Om}\right) \]
      3. associate-/l*33.9%

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

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{\ell \cdot ky}{\frac{Om}{\ell} \cdot \frac{Om}{ky}}} \]
    10. Applied egg-rr34.5%

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

      \[\leadsto 1 + -0.5 \cdot \frac{\ell \cdot ky}{\color{blue}{\frac{{Om}^{2}}{ky \cdot \ell}}} \]
    12. Step-by-step derivation
      1. *-commutative35.9%

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

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

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

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

Alternative 9: 40.7% accurate, 48.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 43.1% accurate, 48.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{1 + -0.5 \cdot \left(\frac{ky \cdot ky}{Om} \cdot \frac{\ell \cdot \ell}{Om}\right)} \]
  9. Step-by-step derivation
    1. *-commutative39.4%

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

      \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\frac{\ell}{\frac{Om}{\ell}}} \cdot \frac{ky \cdot ky}{Om}\right) \]
    3. associate-/l*43.8%

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

      \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{\ell \cdot ky}{\frac{Om}{\ell} \cdot \frac{Om}{ky}}} \]
  10. Applied egg-rr48.0%

    \[\leadsto 1 + -0.5 \cdot \color{blue}{\frac{\ell \cdot ky}{\frac{Om}{\ell} \cdot \frac{Om}{ky}}} \]
  11. Step-by-step derivation
    1. times-frac43.8%

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

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

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

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

Reproduce

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