
(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:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(+
0.5
(*
0.5
(/
1.0
(cbrt
(pow
(hypot 1.0 (* (* l (/ 2.0 Om)) (hypot (sin kx) (sin ky))))
3.0)))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / cbrt(pow(hypot(1.0, ((l * (2.0 / Om)) * hypot(sin(kx), sin(ky)))), 3.0))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.cbrt(Math.pow(Math.hypot(1.0, ((l * (2.0 / Om)) * Math.hypot(Math.sin(kx), Math.sin(ky)))), 3.0))))));
}
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / cbrt((hypot(1.0, Float64(Float64(l * Float64(2.0 / Om)) * hypot(sin(kx), sin(ky)))) ^ 3.0)))))) end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Power[N[Power[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], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt[3]{{\left(\mathsf{hypot}\left(1, \left(\ell \cdot \frac{2}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)}^{3}}}}
\end{array}
Initial program 97.3%
Simplified97.3%
add-cbrt-cube97.3%
pow397.3%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (hypot 1.0 (* (* l (/ 2.0 Om)) (hypot (sin kx) (sin ky)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((l * (2.0 / Om)) * hypot(sin(kx), sin(ky))))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((l * (2.0 / Om)) * Math.hypot(Math.sin(kx), Math.sin(ky))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((l * (2.0 / Om)) * math.hypot(math.sin(kx), math.sin(ky))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(l * Float64(2.0 / Om)) * hypot(sin(kx), sin(ky)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((l * (2.0 / Om)) * hypot(sin(kx), sin(ky)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \left(\ell \cdot \frac{2}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}}
\end{array}
Initial program 97.3%
Simplified97.3%
add-sqr-sqrt97.3%
hypot-1-def97.3%
sqrt-prod97.3%
unpow297.3%
sqrt-prod57.0%
add-sqr-sqrt97.7%
associate-/r/97.7%
*-commutative97.7%
unpow297.7%
unpow297.7%
hypot-def100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (/ (* 2.0 (* l (sin ky))) Om)))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * sin(ky))) / Om))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((2.0 * (l * Math.sin(ky))) / Om))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((2.0 * (l * math.sin(ky))) / Om))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(2.0 * Float64(l * sin(ky))) / Om)))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * sin(ky))) / Om)))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{2 \cdot \left(\ell \cdot \sin ky\right)}{Om}\right)}}
\end{array}
Initial program 97.3%
Simplified97.3%
add-sqr-sqrt97.3%
hypot-1-def97.3%
sqrt-prod97.3%
unpow297.3%
sqrt-prod57.0%
add-sqr-sqrt97.7%
associate-/r/97.7%
*-commutative97.7%
unpow297.7%
unpow297.7%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 95.5%
associate-*r/95.5%
Simplified95.5%
Final simplification95.5%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 5e-80) 1.0 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (/ (* 2.0 (* l ky)) Om))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 5e-80) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * ky)) / Om))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 5e-80) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((2.0 * (l * ky)) / Om))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 5e-80: tmp = 1.0 else: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((2.0 * (l * ky)) / Om)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 5e-80) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(2.0 * Float64(l * ky)) / Om)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 5e-80) tmp = 1.0; else tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * ky)) / Om)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 5e-80], 1.0, N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l * ky), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 5 \cdot 10^{-80}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{2 \cdot \left(\ell \cdot ky\right)}{Om}\right)}}\\
\end{array}
\end{array}
if l < 5e-80Initial program 98.3%
Simplified98.3%
add-sqr-sqrt98.3%
hypot-1-def98.3%
sqrt-prod98.3%
unpow298.3%
sqrt-prod62.8%
add-sqr-sqrt98.9%
associate-/r/98.9%
*-commutative98.9%
unpow298.9%
unpow298.9%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 97.4%
associate-*r/97.4%
Simplified97.4%
Taylor expanded in l around 0 72.5%
if 5e-80 < l Initial program 94.7%
Simplified94.7%
add-sqr-sqrt94.7%
hypot-1-def94.7%
sqrt-prod94.7%
unpow294.7%
sqrt-prod43.4%
add-sqr-sqrt95.0%
associate-/r/95.0%
*-commutative95.0%
unpow295.0%
unpow295.0%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 91.1%
associate-*r/91.1%
Simplified91.1%
Taylor expanded in ky around 0 83.7%
associate-*r/83.7%
*-commutative83.7%
Simplified83.7%
Final simplification75.8%
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 8.4e-166)
(sqrt 0.5)
(if (<= Om 9e+97)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (/ (* (* l l) (* ky ky)) (* Om Om))))))))
1.0)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 8.4e-166) {
tmp = sqrt(0.5);
} else if (Om <= 9e+97) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * (((l * l) * (ky * ky)) / (Om * Om))))))));
} 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 <= 8.4d-166) then
tmp = sqrt(0.5d0)
else if (om <= 9d+97) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * (((l * l) * (ky * ky)) / (om * om))))))))
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 <= 8.4e-166) {
tmp = Math.sqrt(0.5);
} else if (Om <= 9e+97) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * (((l * l) * (ky * ky)) / (Om * Om))))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 8.4e-166: tmp = math.sqrt(0.5) elif Om <= 9e+97: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * (((l * l) * (ky * ky)) / (Om * Om)))))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 8.4e-166) tmp = sqrt(0.5); elseif (Om <= 9e+97) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(Float64(l * l) * Float64(ky * ky)) / Float64(Om * Om)))))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 8.4e-166) tmp = sqrt(0.5); elseif (Om <= 9e+97) tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * (((l * l) * (ky * ky)) / (Om * Om)))))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 8.4e-166], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 9e+97], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(N[(l * l), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 8.4 \cdot 10^{-166}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 9 \cdot 10^{+97}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\left(\ell \cdot \ell\right) \cdot \left(ky \cdot ky\right)}{Om \cdot Om}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 8.3999999999999998e-166Initial program 96.4%
Simplified96.4%
Taylor expanded in Om around 0 49.7%
unpow249.7%
unpow249.7%
hypot-def53.3%
Simplified53.3%
Taylor expanded in l around inf 61.2%
if 8.3999999999999998e-166 < Om < 8.99999999999999952e97Initial program 98.1%
Simplified98.1%
Taylor expanded in kx around 0 87.7%
*-commutative87.7%
associate-/l*87.7%
associate-*l/87.7%
unpow287.7%
unpow287.7%
Simplified87.7%
Taylor expanded in ky around 0 78.2%
*-commutative78.2%
unpow278.2%
unpow278.2%
unpow278.2%
Simplified78.2%
if 8.99999999999999952e97 < Om Initial program 100.0%
Simplified100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
unpow2100.0%
sqrt-prod72.2%
add-sqr-sqrt100.0%
associate-/r/100.0%
*-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in l around 0 100.0%
Final simplification70.2%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 50000000.0) 1.0 (sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 50000000.0) {
tmp = 1.0;
} else {
tmp = sqrt(0.5);
}
return tmp;
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8) :: tmp
if (l <= 50000000.0d0) then
tmp = 1.0d0
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 50000000.0) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 50000000.0: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 50000000.0) tmp = 1.0; else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 50000000.0) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 50000000.0], 1.0, N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 50000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 5e7Initial program 98.5%
Simplified98.5%
add-sqr-sqrt98.5%
hypot-1-def98.5%
sqrt-prod98.5%
unpow298.5%
sqrt-prod60.8%
add-sqr-sqrt99.0%
associate-/r/99.0%
*-commutative99.0%
unpow299.0%
unpow299.0%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 95.9%
associate-*r/95.9%
Simplified95.9%
Taylor expanded in l around 0 71.5%
if 5e7 < l Initial program 93.0%
Simplified93.0%
Taylor expanded in Om around 0 69.5%
unpow269.5%
unpow269.5%
hypot-def76.5%
Simplified76.5%
Taylor expanded in l around inf 80.3%
Final simplification73.5%
(FPCore (l Om kx ky) :precision binary64 (sqrt 0.5))
double code(double l, double Om, double kx, double ky) {
return sqrt(0.5);
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(0.5d0)
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(0.5);
}
def code(l, Om, kx, ky): return math.sqrt(0.5)
function code(l, Om, kx, ky) return sqrt(0.5) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(0.5); end
code[l_, Om_, kx_, ky_] := N[Sqrt[0.5], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5}
\end{array}
Initial program 97.3%
Simplified97.3%
Taylor expanded in Om around 0 42.8%
unpow242.8%
unpow242.8%
hypot-def45.2%
Simplified45.2%
Taylor expanded in l around inf 54.7%
Final simplification54.7%
herbie shell --seed 2023271
(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))))))))))