
(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 8 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 (hypot 1.0 (* (hypot (sin kx) (sin ky)) (* (/ 2.0 Om) l))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (hypot(sin(kx), sin(ky)) * ((2.0 / Om) * l)))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, (Math.hypot(Math.sin(kx), Math.sin(ky)) * ((2.0 / Om) * l)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (math.hypot(math.sin(kx), math.sin(ky)) * ((2.0 / Om) * l)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(hypot(sin(kx), sin(ky)) * Float64(Float64(2.0 / Om) * l))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (hypot(sin(kx), sin(ky)) * ((2.0 / Om) * l))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(2.0 / Om), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(\frac{2}{Om} \cdot \ell\right)\right)}}
\end{array}
Initial program 99.2%
Simplified99.2%
*-un-lft-identity99.2%
add-sqr-sqrt99.2%
hypot-1-def99.2%
sqrt-prod99.2%
sqrt-pow199.3%
metadata-eval99.3%
pow199.3%
clear-num99.3%
un-div-inv99.3%
unpow299.3%
unpow299.3%
hypot-define100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (sqrt (+ 1.0 (* 4.0 (pow (* (sin ky) (/ l Om)) 2.0)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * pow((sin(ky) * (l / Om)), 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((0.5d0 + (0.5d0 * (1.0d0 / sqrt((1.0d0 + (4.0d0 * ((sin(ky) * (l / om)) ** 2.0d0))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + (4.0 * Math.pow((Math.sin(ky) * (l / Om)), 2.0))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + (4.0 * math.pow((math.sin(ky) * (l / Om)), 2.0))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(4.0 * (Float64(sin(ky) * Float64(l / Om)) ^ 2.0)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * ((sin(ky) * (l / Om)) ^ 2.0)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(4.0 * N[Power[N[(N[Sin[ky], $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + 4 \cdot {\left(\sin ky \cdot \frac{\ell}{Om}\right)}^{2}}}}
\end{array}
Initial program 99.2%
Simplified99.2%
Taylor expanded in kx around 0 79.7%
*-commutative79.7%
associate-/l*81.3%
unpow281.3%
unpow281.3%
times-frac92.6%
unpow292.6%
Simplified92.6%
pow-prod-down95.0%
Applied egg-rr95.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 3e+132) (cbrt (pow (+ 0.5 (/ 0.5 (hypot 1.0 (/ (* l (* ky 2.0)) Om)))) 1.5)) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) (* 2.0 (/ l Om)))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 3e+132) {
tmp = cbrt(pow((0.5 + (0.5 / hypot(1.0, ((l * (ky * 2.0)) / Om)))), 1.5));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (2.0 * (l / Om)))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 3e+132) {
tmp = Math.cbrt(Math.pow((0.5 + (0.5 / Math.hypot(1.0, ((l * (ky * 2.0)) / Om)))), 1.5));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) * (2.0 * (l / Om)))))));
}
return tmp;
}
function code(l, Om, kx, ky) tmp = 0.0 if (ky <= 3e+132) tmp = cbrt((Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(l * Float64(ky * 2.0)) / Om)))) ^ 1.5)); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * Float64(2.0 * Float64(l / Om))))))); end return tmp end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 3e+132], N[Power[N[Power[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(l * N[(ky * 2.0), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3 \cdot 10^{+132}:\\
\;\;\;\;\sqrt[3]{{\left(0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\ell \cdot \left(ky \cdot 2\right)}{Om}\right)}\right)}^{1.5}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}\\
\end{array}
\end{array}
if ky < 2.9999999999999998e132Initial program 99.1%
Simplified99.1%
Taylor expanded in kx around 0 78.2%
*-commutative78.2%
associate-/l*80.0%
unpow280.0%
unpow280.0%
times-frac91.6%
unpow291.6%
Simplified91.6%
Taylor expanded in ky around inf 78.2%
metadata-eval78.2%
metadata-eval78.2%
associate-/l*80.0%
unpow280.0%
unpow280.0%
unpow280.0%
times-frac84.0%
swap-sqr94.4%
associate-/l*94.4%
associate-/l*94.4%
swap-sqr94.4%
unpow294.4%
*-commutative94.4%
associate-*r/94.4%
unpow294.4%
Simplified94.4%
Taylor expanded in ky around 0 90.2%
add-cbrt-cube90.2%
add-sqr-sqrt90.2%
pow190.2%
pow1/290.2%
pow-prod-up90.2%
un-div-inv90.2%
associate-*r*90.2%
metadata-eval90.2%
Applied egg-rr90.2%
if 2.9999999999999998e132 < ky Initial program 100.0%
Simplified100.0%
*-un-lft-identity100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
sqrt-pow1100.0%
metadata-eval100.0%
pow1100.0%
clear-num100.0%
un-div-inv100.0%
unpow2100.0%
unpow2100.0%
hypot-define100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.3%
*-un-lft-identity94.3%
un-div-inv94.3%
*-commutative94.3%
Applied egg-rr94.3%
*-lft-identity94.3%
associate-*r/94.3%
*-commutative94.3%
associate-*r/94.3%
Simplified94.3%
Final simplification90.7%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 7e+132) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ l Om) (* ky 2.0)))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) (* 2.0 (/ l Om)))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 7e+132) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (ky * 2.0))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (2.0 * (l / Om)))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 7e+132) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((l / Om) * (ky * 2.0))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) * (2.0 * (l / Om)))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if ky <= 7e+132: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((l / Om) * (ky * 2.0)))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) * (2.0 * (l / Om))))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (ky <= 7e+132) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(l / Om) * Float64(ky * 2.0)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * Float64(2.0 * Float64(l / Om))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (ky <= 7e+132) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (ky * 2.0)))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (2.0 * (l / Om))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 7e+132], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(l / Om), $MachinePrecision] * N[(ky * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 7 \cdot 10^{+132}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\ell}{Om} \cdot \left(ky \cdot 2\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}\\
\end{array}
\end{array}
if ky < 7.00000000000000041e132Initial program 99.1%
Simplified99.1%
Taylor expanded in kx around 0 78.2%
*-commutative78.2%
associate-/l*80.0%
unpow280.0%
unpow280.0%
times-frac91.6%
unpow291.6%
Simplified91.6%
Taylor expanded in ky around inf 78.2%
metadata-eval78.2%
metadata-eval78.2%
associate-/l*80.0%
unpow280.0%
unpow280.0%
unpow280.0%
times-frac84.0%
swap-sqr94.4%
associate-/l*94.4%
associate-/l*94.4%
swap-sqr94.4%
unpow294.4%
*-commutative94.4%
associate-*r/94.4%
unpow294.4%
Simplified94.4%
Taylor expanded in ky around 0 90.2%
*-un-lft-identity90.2%
un-div-inv90.2%
associate-*r*90.2%
Applied egg-rr90.2%
*-lft-identity90.2%
associate-/l*90.2%
Simplified90.2%
if 7.00000000000000041e132 < ky Initial program 100.0%
Simplified100.0%
*-un-lft-identity100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
sqrt-pow1100.0%
metadata-eval100.0%
pow1100.0%
clear-num100.0%
un-div-inv100.0%
unpow2100.0%
unpow2100.0%
hypot-define100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.3%
*-un-lft-identity94.3%
un-div-inv94.3%
*-commutative94.3%
Applied egg-rr94.3%
*-lft-identity94.3%
associate-*r/94.3%
*-commutative94.3%
associate-*r/94.3%
Simplified94.3%
Final simplification90.7%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (/ (* (sin ky) (* 2.0 l)) Om)))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((sin(ky) * (2.0 * l)) / Om))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((Math.sin(ky) * (2.0 * l)) / Om))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((math.sin(ky) * (2.0 * l)) / Om))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(sin(ky) * Float64(2.0 * l)) / Om)))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((sin(ky) * (2.0 * l)) / 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[(N[Sin[ky], $MachinePrecision] * N[(2.0 * l), $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{\sin ky \cdot \left(2 \cdot \ell\right)}{Om}\right)}}
\end{array}
Initial program 99.2%
Simplified99.2%
Taylor expanded in kx around 0 79.7%
*-commutative79.7%
associate-/l*81.3%
unpow281.3%
unpow281.3%
times-frac92.6%
unpow292.6%
Simplified92.6%
Taylor expanded in ky around inf 79.7%
metadata-eval79.7%
metadata-eval79.7%
associate-/l*81.3%
unpow281.3%
unpow281.3%
unpow281.3%
times-frac84.8%
swap-sqr95.0%
associate-/l*95.0%
associate-/l*95.0%
swap-sqr95.0%
unpow295.0%
*-commutative95.0%
associate-*r/95.0%
unpow295.0%
Simplified95.0%
Final simplification95.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 8.2e-76) 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ l Om) (* ky 2.0))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 8.2e-76) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (ky * 2.0))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 8.2e-76) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((l / Om) * (ky * 2.0))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 8.2e-76: tmp = 1.0 else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((l / Om) * (ky * 2.0)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 8.2e-76) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(l / Om) * Float64(ky * 2.0)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 8.2e-76) tmp = 1.0; else tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (ky * 2.0)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 8.2e-76], 1.0, N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(l / Om), $MachinePrecision] * N[(ky * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 8.2 \cdot 10^{-76}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\ell}{Om} \cdot \left(ky \cdot 2\right)\right)}}\\
\end{array}
\end{array}
if l < 8.1999999999999996e-76Initial program 98.9%
Simplified98.9%
*-un-lft-identity98.9%
add-sqr-sqrt98.9%
hypot-1-def98.9%
sqrt-prod98.9%
sqrt-pow199.0%
metadata-eval99.0%
pow199.0%
clear-num99.0%
un-div-inv99.0%
unpow299.0%
unpow299.0%
hypot-define100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.4%
*-un-lft-identity94.4%
un-div-inv94.4%
*-commutative94.4%
Applied egg-rr94.4%
*-lft-identity94.4%
associate-*r/94.4%
*-commutative94.4%
associate-*r/94.4%
Simplified94.4%
Taylor expanded in kx around 0 68.3%
if 8.1999999999999996e-76 < l Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 77.2%
*-commutative77.2%
associate-/l*77.2%
unpow277.2%
unpow277.2%
times-frac91.4%
unpow291.4%
Simplified91.4%
Taylor expanded in ky around inf 77.2%
metadata-eval77.2%
metadata-eval77.2%
associate-/l*77.2%
unpow277.2%
unpow277.2%
unpow277.2%
times-frac78.5%
swap-sqr92.7%
associate-/l*92.7%
associate-/l*92.7%
swap-sqr92.7%
unpow292.7%
*-commutative92.7%
associate-*r/92.7%
unpow292.7%
Simplified92.7%
Taylor expanded in ky around 0 90.3%
*-un-lft-identity90.3%
un-div-inv90.3%
associate-*r*90.3%
Applied egg-rr90.3%
*-lft-identity90.3%
associate-/l*90.3%
Simplified90.3%
Final simplification75.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 4e-25) (sqrt 0.5) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 4e-25) {
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 <= 4d-25) 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 <= 4e-25) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 4e-25: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 4e-25) 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 <= 4e-25) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 4e-25], N[Sqrt[0.5], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 4 \cdot 10^{-25}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 4.00000000000000015e-25Initial program 98.9%
Simplified98.9%
Taylor expanded in l around inf 56.5%
*-commutative56.5%
*-commutative56.5%
associate-*l*56.5%
unpow256.5%
unpow256.5%
hypot-undefine57.6%
associate-*l/57.6%
associate-/l*57.6%
Simplified57.6%
Taylor expanded in l around inf 64.9%
if 4.00000000000000015e-25 < Om Initial program 100.0%
Simplified100.0%
*-un-lft-identity100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
sqrt-pow1100.0%
metadata-eval100.0%
pow1100.0%
clear-num100.0%
un-div-inv100.0%
unpow2100.0%
unpow2100.0%
hypot-define100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in ky around 0 91.0%
*-un-lft-identity91.0%
un-div-inv91.0%
*-commutative91.0%
Applied egg-rr91.0%
*-lft-identity91.0%
associate-*r/91.0%
*-commutative91.0%
associate-*r/91.0%
Simplified91.0%
Taylor expanded in kx around 0 81.3%
(FPCore (l Om kx ky) :precision binary64 1.0)
double code(double l, double Om, double kx, double ky) {
return 1.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 = 1.0d0
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0;
}
def code(l, Om, kx, ky): return 1.0
function code(l, Om, kx, ky) return 1.0 end
function tmp = code(l, Om, kx, ky) tmp = 1.0; end
code[l_, Om_, kx_, ky_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.2%
Simplified99.2%
*-un-lft-identity99.2%
add-sqr-sqrt99.2%
hypot-1-def99.2%
sqrt-prod99.2%
sqrt-pow199.3%
metadata-eval99.3%
pow199.3%
clear-num99.3%
un-div-inv99.3%
unpow299.3%
unpow299.3%
hypot-define100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in ky around 0 92.8%
*-un-lft-identity92.8%
un-div-inv92.8%
*-commutative92.8%
Applied egg-rr92.8%
*-lft-identity92.8%
associate-*r/92.8%
*-commutative92.8%
associate-*r/92.8%
Simplified92.8%
Taylor expanded in kx around 0 61.5%
herbie shell --seed 2024089
(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))))))))))